index.js 813 B

1234567891011121314151617181920212223242526272829303132
  1. import Authorized from './Authorized';
  2. import AuthorizedRoute from './AuthorizedRoute';
  3. import Secured from './Secured';
  4. import check from './CheckPermissions.js';
  5. /* eslint-disable import/no-mutable-exports */
  6. let CURRENT = 'NULL';
  7. Authorized.Secured = Secured;
  8. Authorized.AuthorizedRoute = AuthorizedRoute;
  9. Authorized.check = check;
  10. /**
  11. * use authority or getAuthority
  12. * @param {string|()=>String} currentAuthority
  13. */
  14. const renderAuthorize = currentAuthority => {
  15. if (currentAuthority) {
  16. if (currentAuthority.constructor.name === 'Function') {
  17. CURRENT = currentAuthority();
  18. }
  19. if (currentAuthority.constructor.name === 'String') {
  20. CURRENT = currentAuthority;
  21. }
  22. } else {
  23. CURRENT = 'NULL';
  24. }
  25. return Authorized;
  26. };
  27. export { CURRENT };
  28. export default renderAuthorize;