Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PrivateRoute extends React.Component<Props> {
- render() {
- const {
- component: Component,
- exact,
- path,
- checkingSession,
- user
- } = this.props;
- return (
- <Route
- exact={exact}
- path={path}
- render={() => {
- if (checkingSession) {
- return <div />;
- }
- if (!auth0Client.isAuthenticated()) {
- return <LoginPage />;
- }
- const missingRoles: boolean = !user.roles.length;
- const emailNotVerified: boolean = !user.emailVerified;
- if (missingRoles || !user.emailVerified) {
- return (
- <>
- <TopBar logout={auth0Client.signOut} user={user}/>
- <FullScreenContentWrapper>
- <NoPermissionBox
- missingRoles={missingRoles}
- emailNotVerified={emailNotVerified}
- />
- </FullScreenContentWrapper>
- </>
- );
- }
- return (
- <>
- <TopBar logout={auth0Client.signOut} user={user} />
- <ContentWrapper>
- <NavBar />
- <Content>
- <Component />
- </Content>
- </ContentWrapper>
- </>
- )
- }}
- />
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement