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

View file

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