fix: OIDC finalization and refactoring
This commit is contained in:
@@ -10,6 +10,7 @@ const initialState = {
|
||||
export default (state = initialState, { type, payload }) => {
|
||||
switch (type) {
|
||||
case ActionTypes.AUTHENTICATE__SUCCESS:
|
||||
case ActionTypes.WITH_OIDC_AUTHENTICATE__SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
accessToken: payload.accessToken,
|
||||
|
||||
@@ -4,7 +4,6 @@ import ActionTypes from '../constants/ActionTypes';
|
||||
import ModalTypes from '../constants/ModalTypes';
|
||||
|
||||
const initialState = {
|
||||
isInitializing: true,
|
||||
isLogouting: false,
|
||||
currentModal: null,
|
||||
};
|
||||
@@ -18,11 +17,6 @@ export default (state = initialState, { type, payload }) => {
|
||||
...state,
|
||||
currentModal: null,
|
||||
};
|
||||
case ActionTypes.CORE_INITIALIZE:
|
||||
return {
|
||||
...state,
|
||||
isInitializing: false,
|
||||
};
|
||||
case ActionTypes.LOGOUT__ACCESS_TOKEN_INVALIDATE:
|
||||
return {
|
||||
...state,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { combineReducers } from 'redux';
|
||||
import router from './router';
|
||||
import socket from './socket';
|
||||
import orm from './orm';
|
||||
import root from './root';
|
||||
import auth from './auth';
|
||||
import core from './core';
|
||||
import ui from './ui';
|
||||
@@ -11,6 +12,7 @@ export default combineReducers({
|
||||
router,
|
||||
socket,
|
||||
orm,
|
||||
root,
|
||||
auth,
|
||||
core,
|
||||
ui,
|
||||
|
||||
34
client/src/reducers/root.js
Normal file
34
client/src/reducers/root.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
const initialState = {
|
||||
isInitializing: true,
|
||||
config: null,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line default-param-last
|
||||
export default (state = initialState, { type, payload }) => {
|
||||
switch (type) {
|
||||
case ActionTypes.LOGIN_INITIALIZE:
|
||||
return {
|
||||
...state,
|
||||
isInitializing: false,
|
||||
config: payload.config,
|
||||
};
|
||||
case ActionTypes.AUTHENTICATE__SUCCESS:
|
||||
case ActionTypes.WITH_OIDC_AUTHENTICATE__SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
isInitializing: true,
|
||||
};
|
||||
case ActionTypes.CORE_INITIALIZE:
|
||||
return {
|
||||
...state,
|
||||
isInitializing: false,
|
||||
...(payload.config && {
|
||||
config: payload.config,
|
||||
}),
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
@@ -1,4 +1,7 @@
|
||||
import { LOCATION_CHANGE_HANDLE } from '../../lib/redux-router';
|
||||
|
||||
import ActionTypes from '../../constants/ActionTypes';
|
||||
import Paths from '../../constants/Paths';
|
||||
|
||||
const initialState = {
|
||||
data: {
|
||||
@@ -6,12 +9,22 @@ const initialState = {
|
||||
password: '',
|
||||
},
|
||||
isSubmitting: false,
|
||||
isSubmittingWithOidc: false,
|
||||
error: null,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line default-param-last
|
||||
export default (state = initialState, { type, payload }) => {
|
||||
switch (type) {
|
||||
case LOCATION_CHANGE_HANDLE:
|
||||
if (payload.location.pathname === Paths.OIDC_CALLBACK) {
|
||||
return {
|
||||
...state,
|
||||
isSubmittingWithOidc: true,
|
||||
};
|
||||
}
|
||||
|
||||
return state;
|
||||
case ActionTypes.AUTHENTICATE:
|
||||
return {
|
||||
...state,
|
||||
@@ -22,6 +35,7 @@ export default (state = initialState, { type, payload }) => {
|
||||
isSubmitting: true,
|
||||
};
|
||||
case ActionTypes.AUTHENTICATE__SUCCESS:
|
||||
case ActionTypes.WITH_OIDC_AUTHENTICATE__SUCCESS:
|
||||
return initialState;
|
||||
case ActionTypes.AUTHENTICATE__FAILURE:
|
||||
return {
|
||||
@@ -29,6 +43,12 @@ export default (state = initialState, { type, payload }) => {
|
||||
isSubmitting: false,
|
||||
error: payload.error,
|
||||
};
|
||||
case ActionTypes.WITH_OIDC_AUTHENTICATE__FAILURE:
|
||||
return {
|
||||
...state,
|
||||
isSubmittingWithOidc: false,
|
||||
error: payload.error,
|
||||
};
|
||||
case ActionTypes.AUTHENTICATE_ERROR_CLEAR:
|
||||
return {
|
||||
...state,
|
||||
|
||||
Reference in New Issue
Block a user