Commit 295580c0 authored by jim's avatar jim

add Secured check instantiation

parent a7981496
...@@ -9,6 +9,17 @@ const Exception403 = () => ( ...@@ -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) => { ...@@ -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);
}; };
}; };
......
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