From 4e7e57dfd92970bcf35bfab9a29f0df2e155c6cd Mon Sep 17 00:00:00 2001 From: Maksim Eltyshev Date: Fri, 20 Oct 2023 22:34:58 +0200 Subject: [PATCH] fix: Fix logging out with invalid token --- client/src/actions/core.js | 10 ++++++++-- client/src/constants/ActionTypes.js | 1 + client/src/reducers/root.js | 8 +++++--- client/src/sagas/core/services/core.js | 3 ++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/client/src/actions/core.js b/client/src/actions/core.js index 81dbbba0..2d585874 100644 --- a/client/src/actions/core.js +++ b/client/src/actions/core.js @@ -1,7 +1,6 @@ import ActionTypes from '../constants/ActionTypes'; const initializeCore = ( - config, user, board, users, @@ -21,7 +20,6 @@ const initializeCore = ( ) => ({ type: ActionTypes.CORE_INITIALIZE, payload: { - config, user, board, users, @@ -41,6 +39,14 @@ const initializeCore = ( }, }); +// TODO: with success? +initializeCore.fetchConfig = (config) => ({ + type: ActionTypes.CORE_INITIALIZE__CONFIG_FETCH, + payload: { + config, + }, +}); + const logout = () => ({ type: ActionTypes.LOGOUT, payload: {}, diff --git a/client/src/constants/ActionTypes.js b/client/src/constants/ActionTypes.js index 255160c3..02483d98 100644 --- a/client/src/constants/ActionTypes.js +++ b/client/src/constants/ActionTypes.js @@ -24,6 +24,7 @@ export default { /* Core */ CORE_INITIALIZE: 'CORE_INITIALIZE', + CORE_INITIALIZE__CONFIG_FETCH: 'CORE_INITIALIZE__CONFIG_FETCH', LOGOUT: 'LOGOUT', LOGOUT__ACCESS_TOKEN_INVALIDATE: 'LOGOUT__ACCESS_TOKEN_INVALIDATE', diff --git a/client/src/reducers/root.js b/client/src/reducers/root.js index c40be985..4a74c96d 100644 --- a/client/src/reducers/root.js +++ b/client/src/reducers/root.js @@ -24,9 +24,11 @@ export default (state = initialState, { type, payload }) => { return { ...state, isInitializing: false, - ...(payload.config && { - config: payload.config, - }), + }; + case ActionTypes.CORE_INITIALIZE__CONFIG_FETCH: + return { + ...state, + config: payload.config, }; default: return state; diff --git a/client/src/sagas/core/services/core.js b/client/src/sagas/core/services/core.js index 2dea7ea1..cd694136 100644 --- a/client/src/sagas/core/services/core.js +++ b/client/src/sagas/core/services/core.js @@ -14,6 +14,8 @@ export function* initializeCore() { let config; if (!currentConfig) { ({ item: config } = yield call(api.getConfig)); // TODO: handle error + + yield put(actions.initializeCore.fetchConfig(config)); } const { @@ -40,7 +42,6 @@ export function* initializeCore() { yield put( actions.initializeCore( - config, user, board, users,