renderAuthorize.js 651 Bytes
Newer Older
陈帅's avatar
陈帅 committed
1 2 3 4 5 6
/* eslint-disable import/no-mutable-exports */
let CURRENT = 'NULL';
/**
 * use  authority or getAuthority
 * @param {string|()=>String} currentAuthority
 */
7 8 9 10
const renderAuthorize = Authorized => currentAuthority => {
  if (currentAuthority) {
    if (currentAuthority.constructor.name === 'Function') {
      CURRENT = currentAuthority();
陈帅's avatar
陈帅 committed
11
    }
12 13 14 15 16 17 18 19 20 21
    if (
      currentAuthority.constructor.name === 'String' ||
      currentAuthority.constructor.name === 'Array'
    ) {
      CURRENT = currentAuthority;
    }
  } else {
    CURRENT = 'NULL';
  }
  return Authorized;
陈帅's avatar
陈帅 committed
22 23 24 25
};

export { CURRENT };
export default Authorized => renderAuthorize(Authorized);