Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/reducers/currentUser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import jwtDecode from 'jwt-decode';
import { hasAuthToken, getAuthToken } from '../actions/authTokenStore';

const initialState = {};

Expand All @@ -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;
}
};
Expand Down