Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class PrivateRoute extends React.Component<Props> {
  2.   render() {
  3.     const {
  4.       component: Component,
  5.       exact,
  6.       path,
  7.       checkingSession,
  8.       user
  9.     } = this.props;
  10.  
  11.     return (
  12.       <Route
  13.         exact={exact}
  14.         path={path}
  15.         render={() => {
  16.           if (checkingSession) {
  17.             return <div />;
  18.           }
  19.  
  20.           if (!auth0Client.isAuthenticated()) {
  21.             return <LoginPage />;
  22.           }
  23.  
  24.           const missingRoles: boolean = !user.roles.length;
  25.           const emailNotVerified: boolean = !user.emailVerified;
  26.  
  27.  
  28.           if (missingRoles || !user.emailVerified) {
  29.             return (
  30.               <>
  31.                 <TopBar logout={auth0Client.signOut} user={user}/>
  32.                 <FullScreenContentWrapper>
  33.                   <NoPermissionBox
  34.                     missingRoles={missingRoles}
  35.                     emailNotVerified={emailNotVerified}
  36.                   />
  37.                 </FullScreenContentWrapper>
  38.               </>
  39.             );
  40.           }
  41.  
  42.           return (
  43.             <>
  44.               <TopBar logout={auth0Client.signOut} user={user} />
  45.               <ContentWrapper>
  46.                 <NavBar />
  47.                 <Content>
  48.                   <Component />
  49.                 </Content>
  50.               </ContentWrapper>
  51.             </>
  52.           )
  53.         }}
  54.       />
  55.     );
  56.   }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement