I am working on one project but I am wondering that if I am already using redux in our application then can we stop using httponly cookie to store token ?
This is my reducer and I am storing the token this way in my reducer. And I am also using redux-persist to persist the user whenever he reload the page.
So, it advisable to store the jwt token like this ?
import * as types from "./user.types";
const initialState = {
token: null,
user: {},
loading: false,
error: null,
};
const authReducer = (state = initialState, action) => {
switch (action.type) {
case types.LOGIN_START:
return {
...state,
loading: true,
};
case types.LOGIN_SUCCESS:
return {
...state,
loading: false,
token: action.payload.jwt,
user: action.payload.user,
};
case types.LOGIN_FAIL:
return {
...state,
loading: false,
error: action.payload,
};
default:
return state;
}
};
export default authReducer;