feat: Store accessToken in cookies instead of localStorage

This commit is contained in:
Maksim Eltyshev
2022-04-26 18:01:55 +05:00
parent cad3233da7
commit 7ef55ec578
27 changed files with 137 additions and 114 deletions

View File

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