mirror of
https://github.com/plankanban/planka.git
synced 2025-12-26 17:25:03 +03:00
feat: Store accessToken in cookies instead of localStorage
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { call, fork, join, put, select, take } from 'redux-saga/effects';
|
||||
import { call, fork, join, put, take } from 'redux-saga/effects';
|
||||
|
||||
import { accessTokenSelector } from '../../selectors';
|
||||
import { logout } from '../../actions';
|
||||
import ErrorCodes from '../../constants/ErrorCodes';
|
||||
|
||||
@@ -13,12 +12,8 @@ function* queueRequest(method, ...args) {
|
||||
} catch {} // eslint-disable-line no-empty
|
||||
}
|
||||
|
||||
const accessToken = yield select(accessTokenSelector);
|
||||
|
||||
try {
|
||||
return yield call(method, ...args, {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
});
|
||||
return yield call(method, ...args);
|
||||
} catch (error) {
|
||||
if (error.code === ErrorCodes.UNAUTHORIZED) {
|
||||
yield put(logout()); // TODO: next url
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { call, select } from 'redux-saga/effects';
|
||||
import { call } from 'redux-saga/effects';
|
||||
|
||||
import loginSaga from './login';
|
||||
import coreSaga from './core';
|
||||
import { accessTokenSelector } from '../selectors';
|
||||
import { getAccessToken } from '../utils/access-token-storage';
|
||||
|
||||
export default function* rootSaga() {
|
||||
const accessToken = yield select(accessTokenSelector);
|
||||
const accessToken = yield call(getAccessToken);
|
||||
|
||||
if (!accessToken) {
|
||||
yield call(loginSaga);
|
||||
|
||||
Reference in New Issue
Block a user