Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2021-09-14 09:30:37 +02:00
parent 706d9b1f6f
commit d6d1b0eeef
2 changed files with 6 additions and 6 deletions

View file

@ -3,7 +3,7 @@ import {
BrowserRouter, Switch, Route, Redirect, BrowserRouter, Switch, Route, Redirect,
} from 'react-router-dom'; } from 'react-router-dom';
import { isAuthanticated } from '../../client/state/auth'; import { isAuthenticated } from '../../client/state/auth';
import Auth from '../templates/auth/Auth'; import Auth from '../templates/auth/Auth';
import Client from '../templates/client/Client'; import Client from '../templates/client/Client';
@ -13,13 +13,13 @@ function App() {
<BrowserRouter> <BrowserRouter>
<Switch> <Switch>
<Route exact path="/"> <Route exact path="/">
{ isAuthanticated() ? <Client /> : <Redirect to="/login" />} { isAuthenticated() ? <Client /> : <Redirect to="/login" />}
</Route> </Route>
<Route path="/login"> <Route path="/login">
{ isAuthanticated() ? <Redirect to="/" /> : <Auth type="login" />} { isAuthenticated() ? <Redirect to="/" /> : <Auth type="login" />}
</Route> </Route>
<Route path="/register"> <Route path="/register">
{ isAuthanticated() ? <Redirect to="/" /> : <Auth type="register" />} { isAuthenticated() ? <Redirect to="/" /> : <Auth type="register" />}
</Route> </Route>
</Switch> </Switch>
</BrowserRouter> </BrowserRouter>

View file

@ -4,7 +4,7 @@ function getSecret(key) {
return localStorage.getItem(key); return localStorage.getItem(key);
} }
const isAuthanticated = () => getSecret(cons.secretKey.ACCESS_TOKEN) !== null; const isAuthenticated = () => getSecret(cons.secretKey.ACCESS_TOKEN) !== null;
const secret = { const secret = {
accessToken: getSecret(cons.secretKey.ACCESS_TOKEN), accessToken: getSecret(cons.secretKey.ACCESS_TOKEN),
@ -14,6 +14,6 @@ const secret = {
}; };
export { export {
isAuthanticated, isAuthenticated,
secret, secret,
}; };