Skip to content

Commit

Permalink
fix: fix token storage
Browse files Browse the repository at this point in the history
  • Loading branch information
whosyourtaco committed Jul 7, 2021
1 parent 350d16e commit d67e394
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/routing/PrivateRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import Layout from 'pages/Layout/Layout';
import { Redirect, Route } from 'react-router-dom';

import { __TOKEN__ } from '../utils/constants';
import cookies from '../utils/cookies';
import { getUserStorageItem } from '../utils/storage';
import { CustomRouteProps } from './types';
import urls from './urls';

const PrivateRoute: React.FC<CustomRouteProps> = ({ component: Component, ...rest }) => {
const token = cookies.get(__TOKEN__);
const token = getUserStorageItem(__TOKEN__);

if (!token) {
return <Route {...rest} render={() => <Redirect to={urls.login()} />} />;
Expand Down
4 changes: 2 additions & 2 deletions src/routing/PublicRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { Redirect, Route } from 'react-router-dom';

import Layout from '../pages/Layout';
import { __TOKEN__ } from '../utils/constants';
import cookies from '../utils/cookies';
import { getUserStorageItem } from '../utils/storage';
import { CustomRouteProps } from './types';
import urls from './urls';

const PublicRoute: React.FC<CustomRouteProps> = ({ component: Component, ...rest }) => {
const token = cookies.get(__TOKEN__);
const token = getUserStorageItem(__TOKEN__);

if (token && rest.path === urls.login()) {
return <Route {...rest} render={() => <Redirect to={urls.patients()} />} />;
Expand Down

0 comments on commit d67e394

Please sign in to comment.