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
fdd6035f
Commit
fdd6035f
authored
Jun 26, 2018
by
ubbcou
Committed by
ιεΈ
Jun 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increase the permission judgment: when the user's permission is an array.
parent
268e0ee5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
1 deletion
+13
-1
src/components/Authorized/CheckPermissions.js
src/components/Authorized/CheckPermissions.js
+8
-0
src/components/Authorized/renderAuthorize.js
src/components/Authorized/renderAuthorize.js
+4
-1
src/utils/authority.js
src/utils/authority.js
+1
-0
No files found.
src/components/Authorized/CheckPermissions.js
View file @
fdd6035f
...
...
@@ -29,6 +29,14 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
if
(
authority
.
indexOf
(
currentAuthority
)
>=
0
)
{
return
target
;
}
if
(
Array
.
isArray
(
currentAuthority
))
{
for
(
let
i
=
0
;
i
<
currentAuthority
.
length
;
i
+=
1
)
{
const
element
=
currentAuthority
[
i
];
if
(
authority
.
indexOf
(
element
)
>=
0
)
{
return
target
;
}
}
}
return
Exception
;
}
...
...
src/components/Authorized/renderAuthorize.js
View file @
fdd6035f
...
...
@@ -10,7 +10,10 @@ const renderAuthorize = Authorized => {
if
(
currentAuthority
.
constructor
.
name
===
'
Function
'
)
{
CURRENT
=
currentAuthority
();
}
if
(
currentAuthority
.
constructor
.
name
===
'
String
'
)
{
if
(
currentAuthority
.
constructor
.
name
===
'
String
'
||
currentAuthority
.
constructor
.
name
===
'
Array
'
)
{
CURRENT
=
currentAuthority
;
}
}
else
{
...
...
src/utils/authority.js
View file @
fdd6035f
// use localStorage to store the authority info, which might be sent from server in actual project.
export
function
getAuthority
()
{
// return localStorage.getItem('antd-pro-authority') || ['admin', 'user'];
return
localStorage
.
getItem
(
'
antd-pro-authority
'
)
||
'
admin
'
;
}
...
...
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