mirror of https://github.com/chillzhuang/Sword
26 lines
651 B
JavaScript
26 lines
651 B
JavaScript
/* eslint-disable import/no-mutable-exports */
|
|
let CURRENT = 'NULL';
|
|
/**
|
|
* use authority or getAuthority
|
|
* @param {string|()=>String} currentAuthority
|
|
*/
|
|
const renderAuthorize = Authorized => currentAuthority => {
|
|
if (currentAuthority) {
|
|
if (typeof currentAuthority === 'function') {
|
|
CURRENT = currentAuthority();
|
|
}
|
|
if (
|
|
Object.prototype.toString.call(currentAuthority) === '[object String]' ||
|
|
Array.isArray(currentAuthority)
|
|
) {
|
|
CURRENT = currentAuthority;
|
|
}
|
|
} else {
|
|
CURRENT = 'NULL';
|
|
}
|
|
return Authorized;
|
|
};
|
|
|
|
export { CURRENT };
|
|
export default Authorized => renderAuthorize(Authorized);
|