diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js index a79e28591eb7440c586d1c04ff83eb7b38702cba..df6fdb7f0ec7504356c28f3868b3e7f3fadc2b3d 100644 --- a/src/components/Authorized/CheckPermissions.js +++ b/src/components/Authorized/CheckPermissions.js @@ -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; } diff --git a/src/components/Authorized/renderAuthorize.js b/src/components/Authorized/renderAuthorize.js index 8e34c6942a2977b9d0a183c9ba277e9cb1ca4ddc..16177edece45ef253789db30d32895344857d5de 100644 --- a/src/components/Authorized/renderAuthorize.js +++ b/src/components/Authorized/renderAuthorize.js @@ -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 { diff --git a/src/utils/authority.js b/src/utils/authority.js index dc2856556239516566520214f00a7106218dce4c..424496b2f9dcc6c3352483a1ce7c68b1587fdbdd 100644 --- a/src/utils/authority.js +++ b/src/utils/authority.js @@ -1,5 +1,6 @@ // 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'; }