diff --git a/src/app/core/auth/auth.reducer.ts b/src/app/core/auth/auth.reducer.ts index 98827d842e..b22063ad77 100644 --- a/src/app/core/auth/auth.reducer.ts +++ b/src/app/core/auth/auth.reducer.ts @@ -8,7 +8,7 @@ import { LogOutErrorAction, RedirectWhenAuthenticationIsRequiredAction, RedirectWhenTokenExpiredAction, - RefreshTokenSuccessAction, + RefreshTokenSuccessAction, RetrieveAuthMethodsSuccessAction, SetRedirectUrlAction } from './auth.actions'; // import models @@ -45,6 +45,9 @@ export interface AuthState { // true when refreshing token refreshing?: boolean; + // sso login url + ssoLoginUrl?: string; + // the authenticated user user?: EPerson; } @@ -56,6 +59,7 @@ const initialState: AuthState = { authenticated: false, loaded: false, loading: false, + ssoLoginUrl: '' }; /** @@ -187,6 +191,23 @@ export function authReducer(state: any = initialState, action: AuthActions): Aut info: undefined, }); + // next three cases are used by shibboleth login + case AuthActionTypes.RETRIEVE_AUTH_METHODS: + return Object.assign({}, state, { + loading: true + }); + + case AuthActionTypes.RETRIEVE_AUTH_METHODS_SUCCESS: + return Object.assign({}, state, { + loading: false, + ssoLoginUrl: (action as RetrieveAuthMethodsSuccessAction).payload + }); + + case AuthActionTypes.RETRIEVE_AUTH_METHODS_ERROR: + return Object.assign({}, state, { + loading: false + }); + case AuthActionTypes.SET_REDIRECT_URL: return Object.assign({}, state, { redirectUrl: (action as SetRedirectUrlAction).payload,