Fix router logic to account for logged out users; closes #4085
Middleware was removed from the `/` route to redirect users without authentication, so now we need to handle this on the front-end properly.
This commit is contained in:
parent
b051718afe
commit
3fceb588fb
5 changed files with 99 additions and 61 deletions
|
@ -1,22 +1,29 @@
|
|||
import React from 'react';
|
||||
import { Route, RouteComponentProps, Switch } from 'react-router-dom';
|
||||
import { Route, Switch, useRouteMatch } from 'react-router-dom';
|
||||
import LoginContainer from '@/components/auth/LoginContainer';
|
||||
import ForgotPasswordContainer from '@/components/auth/ForgotPasswordContainer';
|
||||
import ResetPasswordContainer from '@/components/auth/ResetPasswordContainer';
|
||||
import LoginCheckpointContainer from '@/components/auth/LoginCheckpointContainer';
|
||||
import { NotFound } from '@/components/elements/ScreenBlock';
|
||||
import { useHistory, useLocation } from 'react-router';
|
||||
|
||||
export default ({ location, history, match }: RouteComponentProps) => (
|
||||
<div className={'pt-8 xl:pt-32'}>
|
||||
<Switch location={location}>
|
||||
<Route path={`${match.path}/login`} component={LoginContainer} exact/>
|
||||
<Route path={`${match.path}/login/checkpoint`} component={LoginCheckpointContainer}/>
|
||||
<Route path={`${match.path}/password`} component={ForgotPasswordContainer} exact/>
|
||||
<Route path={`${match.path}/password/reset/:token`} component={ResetPasswordContainer}/>
|
||||
<Route path={`${match.path}/checkpoint`}/>
|
||||
<Route path={'*'}>
|
||||
<NotFound onBack={() => history.push('/auth/login')}/>
|
||||
</Route>
|
||||
</Switch>
|
||||
</div>
|
||||
);
|
||||
export default () => {
|
||||
const history = useHistory();
|
||||
const location = useLocation();
|
||||
const { path } = useRouteMatch();
|
||||
|
||||
return (
|
||||
<div className={'pt-8 xl:pt-32'}>
|
||||
<Switch location={location}>
|
||||
<Route path={`${path}/login`} component={LoginContainer} exact/>
|
||||
<Route path={`${path}/login/checkpoint`} component={LoginCheckpointContainer}/>
|
||||
<Route path={`${path}/password`} component={ForgotPasswordContainer} exact/>
|
||||
<Route path={`${path}/password/reset/:token`} component={ResetPasswordContainer}/>
|
||||
<Route path={`${path}/checkpoint`}/>
|
||||
<Route path={'*'}>
|
||||
<NotFound onBack={() => history.push('/auth/login')}/>
|
||||
</Route>
|
||||
</Switch>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
Reference in a new issue