Commit fdd6035f authored by ubbcou's avatar ubbcou Committed by 陈帅

Increase the permission judgment: when the user's permission is an array.

parent 268e0ee5
......@@ -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;
}
......
......@@ -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 {
......
// 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';
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment