Selaa lähdekoodia

token fix

feature/code-cleanup-joca
Pavle Golubovic 3 vuotta sitten
vanhempi
commit
392b78c39d
2 muutettua tiedostoa jossa 4 lisäystä ja 3 poistoa
  1. 1
    1
      src/store/actions/login/loginActions.js
  2. 3
    2
      src/store/saga/loginSaga.js

+ 1
- 1
src/store/actions/login/loginActions.js Näytä tiedosto

@@ -29,7 +29,7 @@ export const fetchUserError = (payload) => ({
payload,
});

export const updateUserToken = (payload) => ({
export const setUserJwtToken = (payload) => ({
type: UPDATE_USER_JWT_TOKEN,
payload,
});

+ 3
- 2
src/store/saga/loginSaga.js Näytä tiedosto

@@ -15,6 +15,7 @@ import {
fetchUserError,
fetchUserSuccess,
resetLoginState,
setUserJwtToken,
} from "../actions/login/loginActions";
import { LOGIN_PAGE } from "../../constants/pages";
import { addHeaderToken, removeHeaderToken } from "../../request";
@@ -30,7 +31,6 @@ import {
authScopeSetHelper,
} from "../../util/helpers/authScopeHelpers";
import { rejectErrorCodeHelper } from "../../util/helpers/rejectErrorCodeHelper";
import { setUserAccessToken } from "../actions/user/userActions";
import i18next from "i18next";

function* fetchLogin({ payload }) {
@@ -118,7 +118,8 @@ function* logout(payload) {
function* refreshUserToken({payload}) {
try {
const newTokenDecoded = jwt.decode(payload);
yield put(setUserAccessToken({token: payload, exp: newTokenDecoded.exp}));

yield put(setUserJwtToken({token: payload, exp: newTokenDecoded.exp}));
yield call(addHeaderToken, payload);
yield call(authScopeSetHelper, JWT_TOKEN, payload);
}

Loading…
Peruuta
Tallenna