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
P
pro-blocks
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
pro-blocks
Commits
801109ed
Commit
801109ed
authored
Sep 15, 2018
by
陈帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete redundant code
parent
09afe058
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
24 deletions
+5
-24
src/pages/Authorized.js
src/pages/Authorized.js
+5
-24
No files found.
src/pages/Authorized.js
View file @
801109ed
import
React
from
'
react
'
;
import
RenderAuthorized
from
'
@/components/Authorized
'
;
import
Exception
from
'
@/components/Exception
'
;
import
{
getAuthority
}
from
'
@/utils/authority
'
;
import
{
formatMessage
}
from
'
umi/locale
'
;
import
Link
from
'
umi/link
'
;
import
Redirect
from
'
umi/redirect
'
;
const
Authority
=
getAuthority
();
const
Authorized
=
RenderAuthorized
(
Authority
);
export
default
({
children
})
=>
{
let
noMatch
=
(
<
Exception
type
=
"
403
"
desc
=
{
formatMessage
({
id
:
'
app.exception.description.403
'
})}
linkElement
=
{
Link
}
redirect
=
"
/user/login
"
backText
=
"
back to login
"
/>
);
// if Authority === ['guest'] redirect to /user/login
// You can implement the logic here.
if
(
Authority
===
'
guest
'
||
Authority
.
join
(
''
)
===
'
guest
'
)
{
noMatch
=
<
Redirect
to
=
"
/user/login
"
/>
;
}
return
(
<
Authorized
authority
=
{
children
.
props
.
route
.
authority
}
noMatch
=
{
noMatch
}
>
{
children
}
<
/Authorized
>
);
};
export
default
({
children
})
=>
(
<
Authorized
authority
=
{
children
.
props
.
route
.
authority
}
noMatch
=
{
<
Redirect
to
=
"
/user/login
"
/>
}
>
{
children
}
<
/Authorized
>
);
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