From 5c05e84cccbb633a15213c8500f0cbfeb1f9f4e6 Mon Sep 17 00:00:00 2001 From: Francesco Esposito <33671357+frsposito@users.noreply.github.com> Date: Wed, 31 Jul 2019 21:48:36 +0200 Subject: [PATCH] refactor: localStorage -> sessionStorage --- src/PrivateRoute.js | 2 +- src/_helpers/auth-header.js | 2 +- src/_reducers/user.reducer.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PrivateRoute.js b/src/PrivateRoute.js index 8285b3a..17949dd 100644 --- a/src/PrivateRoute.js +++ b/src/PrivateRoute.js @@ -6,7 +6,7 @@ export const PrivateRoute = ({ component: Component, ...rest }) => { ( - localStorage.getItem('user') + sessionStorage.getItem('user') ? : )} diff --git a/src/_helpers/auth-header.js b/src/_helpers/auth-header.js index 3ffe25e..5d28ec2 100644 --- a/src/_helpers/auth-header.js +++ b/src/_helpers/auth-header.js @@ -1,5 +1,5 @@ export function authHeader() { - let user = JSON.parse(localStorage.getItem('user')); + let user = JSON.parse(sessionStorage.getItem('user')); if (user.data.token) { return `Bearer ${user.data.token}` ; diff --git a/src/_reducers/user.reducer.js b/src/_reducers/user.reducer.js index 014ced2..6dd69e3 100644 --- a/src/_reducers/user.reducer.js +++ b/src/_reducers/user.reducer.js @@ -1,6 +1,6 @@ import { userConstants } from '../_constants/user.constants'; -let userLocalStorage = JSON.parse(localStorage.getItem('user')); +let userLocalStorage = JSON.parse(sessionStorage.getItem('user')); const initialState = userLocalStorage ? {loggedIn: true} : {loggedIn: false};