From c7e4983a0608df8e556d877a8083c0e944ea2590 Mon Sep 17 00:00:00 2001
From: xiaohuoni <448627663@qq.com>
Date: Sat, 23 Mar 2019 09:49:26 +0800
Subject: [PATCH] fix: hasLogin redirect to login page
---
src/pages/Authorized.js | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/pages/Authorized.js b/src/pages/Authorized.js
index e2c92e89..5889812b 100644
--- a/src/pages/Authorized.js
+++ b/src/pages/Authorized.js
@@ -3,9 +3,12 @@ import Redirect from 'umi/redirect';
import pathToRegexp from 'path-to-regexp';
import { connect } from 'dva';
import Authorized from '@/utils/Authorized';
+import { getAuthority } from '@/utils/authority';
+import Exception403 from '@/pages/Exception/403';
-function AuthComponent({ children, location, routerData, status }) {
- const isLogin = status === 'ok';
+function AuthComponent({ children, location, routerData }) {
+ const auth = getAuthority();
+ const isLogin = auth && auth[0] !== 'guest';
const getRouteAuthority = (path, routeData) => {
let authorities;
routeData.forEach(route => {
@@ -21,17 +24,15 @@ function AuthComponent({ children, location, routerData, status }) {
});
return authorities;
};
-
return (
: }
+ noMatch={isLogin ? : }
>
{children}
);
}
-export default connect(({ menu: menuModel, login: loginModel }) => ({
+export default connect(({ menu: menuModel }) => ({
routerData: menuModel.routerData,
- status: loginModel.status,
}))(AuthComponent);
--
GitLab