fix: OIDC finalization and refactoring
This commit is contained in:
@@ -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