@ -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 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 {
@ -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';