diff --git a/src/reducers/currentUser.js b/src/reducers/currentUser.js index 9a38a1a..76b81c3 100644 --- a/src/reducers/currentUser.js +++ b/src/reducers/currentUser.js @@ -1,4 +1,5 @@ import jwtDecode from 'jwt-decode'; +import { hasAuthToken, getAuthToken } from '../actions/authTokenStore'; const initialState = {}; @@ -17,6 +18,12 @@ const currentUser = (state = initialState, action) => { case 'LOGIN_FAILED': return initialState; default: + if (Object.keys(state).length === 0 && hasAuthToken()) { // Try to establish init state when it is empty + return { + isLoggedIn: true, + ...jwtDecode(getAuthToken()) + }; + } return state; } };