Просмотр исходного кода

adding jwt token in local storage and redux store

feature/1371_homepage_and_navigation
Dzenis Hadzifejzovic 3 лет назад
Родитель
Сommit
4eab00ad80
2 измененных файлов: 5 добавлений и 5 удалений
  1. 1
    1
      src/store/reducers/login/loginReducer.js
  2. 4
    4
      src/store/saga/loginSaga.js

+ 1
- 1
src/store/reducers/login/loginReducer.js Просмотреть файл

@@ -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 Просмотреть файл

@@ -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));

Загрузка…
Отмена
Сохранить