Przeglądaj źródła

adding jwt token in local storage and redux store

feature/1371_homepage_and_navigation
Dzenis Hadzifejzovic 3 lat temu
rodzic
commit
4eab00ad80

+ 1
- 1
src/store/reducers/login/loginReducer.js Wyświetl plik

@@ -36,7 +36,7 @@ export default createReducer(
function setUser(state, action) {
return {
...state,
user: action.payload,
token: action.payload,
};
}


+ 4
- 4
src/store/saga/loginSaga.js Wyświetl plik

@@ -46,12 +46,12 @@ import { rejectErrorCodeHelper } from '../../util/helpers/rejectErrorCodeHelper'
function* fetchUser({ payload }) {
try {
const { data } = yield call(attemptLogin, payload);
if (data.JwtToken) {
const user = jwt.decode(data.JwtToken);
yield call(authScopeSetHelper, JWT_TOKEN, data.JwtToken);
if (data.token) {
const user = jwt.decode(data.token);
yield call(authScopeSetHelper, JWT_TOKEN, data.token);
yield call(authScopeSetHelper, JWT_REFRESH_TOKEN, data.JwtRefreshToken);
yield call(authScopeSetHelper, REFRESH_TOKEN_CONST, data.RefreshToken);
yield call(addHeaderToken, data.JwtToken);
yield call(addHeaderToken, data.token);
yield put(setUser(user));
}
yield put(fetchUserSuccess(data));

Ładowanie…
Anuluj
Zapisz