Skip to content

Commit 62abf11

Browse files
committed
load user invalid userid fix
1 parent dda2e26 commit 62abf11

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/actions/authAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const loadUser = () => async(dispatch) => {
1616
dispatch(setRequestStatus(true));
1717
localStorage.setItem('userId', res.data.user._id)
1818

19-
dispatch(setCurrentUser(Object.assign({}, res.data.user._id)));
19+
dispatch(setCurrentUser(res.data.user._id));
2020

2121
// Update user name in localStorage
2222
localStorage.setItem('username', `${res.data.user.name.firstName} ${res.data.user.name.lastName}`)

src/reducers/authReducer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const initialState = {
88
isRemoved: false,
99
resetPassReq: null,
1010
passUpdated: false,
11-
user: {},
11+
user: null,
1212
response_msg: "",
1313
};
1414

@@ -17,7 +17,7 @@ export default (state = initialState, action) => {
1717
case SET_CURRENT_USER: {
1818
return {
1919
...state,
20-
isAuthenticated: action.payload.length !== 0,
20+
isAuthenticated: Boolean(action.payload.length !== 0 && action.payload!==undefined && typeof action.payload === 'string'),
2121
user: action.payload
2222
}
2323
}

0 commit comments

Comments
 (0)