浏览代码

token fix

feature/code-cleanup-joca
Pavle Golubovic 3 年前
父节点
当前提交
392b78c39d
共有 2 个文件被更改,包括 4 次插入3 次删除
  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 查看文件

payload, payload,
}); });


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

+ 3
- 2
src/store/saga/loginSaga.js 查看文件

fetchUserError, fetchUserError,
fetchUserSuccess, fetchUserSuccess,
resetLoginState, resetLoginState,
setUserJwtToken,
} from "../actions/login/loginActions"; } from "../actions/login/loginActions";
import { LOGIN_PAGE } from "../../constants/pages"; import { LOGIN_PAGE } from "../../constants/pages";
import { addHeaderToken, removeHeaderToken } from "../../request"; import { addHeaderToken, removeHeaderToken } from "../../request";
authScopeSetHelper, authScopeSetHelper,
} from "../../util/helpers/authScopeHelpers"; } from "../../util/helpers/authScopeHelpers";
import { rejectErrorCodeHelper } from "../../util/helpers/rejectErrorCodeHelper"; import { rejectErrorCodeHelper } from "../../util/helpers/rejectErrorCodeHelper";
import { setUserAccessToken } from "../actions/user/userActions";
import i18next from "i18next"; import i18next from "i18next";


function* fetchLogin({ payload }) { function* fetchLogin({ payload }) {
function* refreshUserToken({payload}) { function* refreshUserToken({payload}) {
try { try {
const newTokenDecoded = jwt.decode(payload); 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(addHeaderToken, payload);
yield call(authScopeSetHelper, JWT_TOKEN, payload); yield call(authScopeSetHelper, JWT_TOKEN, payload);
} }

正在加载...
取消
保存