Browse Source

add Secured check instantiation

pull/877/head
jim 8 years ago
parent
commit
295580c09b
  1. 14
      src/components/Authorized/Secured.js

14
src/components/Authorized/Secured.js

@ -9,6 +9,17 @@ const Exception403 = () => (
<Exception type="403" style={{ minHeight: 500, height: '80%' }} /> <Exception type="403" style={{ minHeight: 500, height: '80%' }} />
); );
// Determine whether the incoming component has been instantiated
// AuthorizedRoute is already instantiated
// Authorized render is already instantiated, children is no instantiated
// Secured is not instantiated
const checkIsInstantiation = (target) => {
if (!React.isValidElement(target)) {
return target;
}
return () => target;
};
/** /**
* 用于判断是否拥有权限访问此view权限 * 用于判断是否拥有权限访问此view权限
* authority 支持传入 string ,funtion:()=>boolean|Promise * authority 支持传入 string ,funtion:()=>boolean|Promise
@ -38,7 +49,8 @@ const authorize = (authority, error) => {
throw new Error('authority is required'); throw new Error('authority is required');
} }
return function decideAuthority(targer) { return function decideAuthority(targer) {
return () => CheckPermissions(authority, targer, classError || Exception403); const component = CheckPermissions(authority, targer, classError || Exception403);
return checkIsInstantiation(component);
}; };
}; };

Loading…
Cancel
Save