commit
14cfa69060
2 changed files with 6 additions and 6 deletions
|
@ -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>
|
||||||
|
|
|
@ -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,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue