diff --git a/src/app/core/auth/auth.actions.ts b/src/app/core/auth/auth.actions.ts index 5680c0017b..0c0d3309b1 100644 --- a/src/app/core/auth/auth.actions.ts +++ b/src/app/core/auth/auth.actions.ts @@ -22,6 +22,7 @@ export const AuthActionTypes = { REFRESH_TOKEN: type('dspace/auth/REFRESH_TOKEN'), REFRESH_TOKEN_SUCCESS: type('dspace/auth/REFRESH_TOKEN_SUCCESS'), REFRESH_TOKEN_ERROR: type('dspace/auth/REFRESH_TOKEN_ERROR'), + ADD_MESSAGE: type('dspace/auth/ADD_MESSAGE'), RESET_MESSAGES: type('dspace/auth/RESET_MESSAGES'), LOG_OUT: type('dspace/auth/LOG_OUT'), LOG_OUT_ERROR: type('dspace/auth/LOG_OUT_ERROR'), @@ -283,6 +284,20 @@ export class RegistrationSuccessAction implements Action { } } +/** + * Add uthentication message. + * @class AddAuthenticationMessageAction + * @implements {Action} + */ +export class AddAuthenticationMessageAction implements Action { + public type: string = AuthActionTypes.ADD_MESSAGE; + payload: string; + + constructor(message: string) { + this.payload = message; + } +} + /** * Reset error. * @class ResetAuthenticationMessagesAction @@ -326,4 +341,6 @@ export type AuthActions | RedirectWhenTokenExpiredAction | RegistrationAction | RegistrationErrorAction - | RegistrationSuccessAction; + | RegistrationSuccessAction + | AddAuthenticationMessageAction + | ResetAuthenticationMessagesAction; diff --git a/src/app/core/auth/auth.reducers.ts b/src/app/core/auth/auth.reducers.ts index b752b8f77f..d45b637f07 100644 --- a/src/app/core/auth/auth.reducers.ts +++ b/src/app/core/auth/auth.reducers.ts @@ -1,5 +1,6 @@ // import actions import { + AddAuthenticationMessageAction, AuthActions, AuthActionTypes, AuthenticatedSuccessAction, AuthenticationErrorAction, AuthenticationSuccessAction, LogOutErrorAction, RedirectWhenAuthenticationIsRequiredAction, RedirectWhenTokenExpiredAction, SetRedirectUrlAction @@ -153,6 +154,11 @@ export function authReducer(state: any = initialState, action: AuthActions): Aut refreshing: false, }); + case AuthActionTypes.ADD_MESSAGE: + return Object.assign({}, state, { + info: (action as AddAuthenticationMessageAction).payload, + }); + case AuthActionTypes.RESET_MESSAGES: return Object.assign({}, state, { authenticated: state.authenticated,