Authorized.jsx 482 B

123456789101112131415161718192021
  1. import React from 'react';
  2. import { Result } from 'antd';
  3. import check from './CheckPermissions';
  4. const Authorized = ({
  5. children,
  6. authority,
  7. noMatch = (
  8. <Result
  9. status="403"
  10. title="403"
  11. subTitle="Sorry, you are not authorized to access this page."
  12. />
  13. ),
  14. }) => {
  15. const childrenRender = typeof children === 'undefined' ? null : children;
  16. const dom = check(authority, childrenRender, noMatch);
  17. return <>{dom}</>;
  18. };
  19. export default Authorized;