Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
c7e4983a
Commit
c7e4983a
authored
Mar 23, 2019
by
xiaohuoni
Committed by
εε³
Mar 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: hasLogin redirect to login page
parent
c51da8bf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
src/pages/Authorized.js
src/pages/Authorized.js
+7
-6
No files found.
src/pages/Authorized.js
View file @
c7e4983a
...
...
@@ -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
(
<
Authorized
authority
=
{
getRouteAuthority
(
location
.
pathname
,
routerData
)}
noMatch
=
{
isLogin
?
<
Redirect
to
=
"
/exception/403
"
/>
:
<
Redirect
to
=
"
/user/login
"
/>
}
noMatch
=
{
isLogin
?
<
Exception403
/>
:
<
Redirect
to
=
"
/user/login
"
/>
}
>
{
children
}
<
/Authorized
>
);
}
export
default
connect
(({
menu
:
menuModel
,
login
:
loginModel
})
=>
({
export
default
connect
(({
menu
:
menuModel
})
=>
({
routerData
:
menuModel
.
routerData
,
status
:
loginModel
.
status
,
}))(
AuthComponent
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment