Added action to insert authentication message

This commit is contained in:
Giuseppe Digilio
2018-04-04 14:49:04 +02:00
parent f841612e1c
commit 934bb603f5
2 changed files with 24 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ export const AuthActionTypes = {
REFRESH_TOKEN: type('dspace/auth/REFRESH_TOKEN'), REFRESH_TOKEN: type('dspace/auth/REFRESH_TOKEN'),
REFRESH_TOKEN_SUCCESS: type('dspace/auth/REFRESH_TOKEN_SUCCESS'), REFRESH_TOKEN_SUCCESS: type('dspace/auth/REFRESH_TOKEN_SUCCESS'),
REFRESH_TOKEN_ERROR: type('dspace/auth/REFRESH_TOKEN_ERROR'), REFRESH_TOKEN_ERROR: type('dspace/auth/REFRESH_TOKEN_ERROR'),
ADD_MESSAGE: type('dspace/auth/ADD_MESSAGE'),
RESET_MESSAGES: type('dspace/auth/RESET_MESSAGES'), RESET_MESSAGES: type('dspace/auth/RESET_MESSAGES'),
LOG_OUT: type('dspace/auth/LOG_OUT'), LOG_OUT: type('dspace/auth/LOG_OUT'),
LOG_OUT_ERROR: type('dspace/auth/LOG_OUT_ERROR'), 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. * Reset error.
* @class ResetAuthenticationMessagesAction * @class ResetAuthenticationMessagesAction
@@ -326,4 +341,6 @@ export type AuthActions
| RedirectWhenTokenExpiredAction | RedirectWhenTokenExpiredAction
| RegistrationAction | RegistrationAction
| RegistrationErrorAction | RegistrationErrorAction
| RegistrationSuccessAction; | RegistrationSuccessAction
| AddAuthenticationMessageAction
| ResetAuthenticationMessagesAction;

View File

@@ -1,5 +1,6 @@
// import actions // import actions
import { import {
AddAuthenticationMessageAction,
AuthActions, AuthActionTypes, AuthenticatedSuccessAction, AuthenticationErrorAction, AuthActions, AuthActionTypes, AuthenticatedSuccessAction, AuthenticationErrorAction,
AuthenticationSuccessAction, LogOutErrorAction, RedirectWhenAuthenticationIsRequiredAction, AuthenticationSuccessAction, LogOutErrorAction, RedirectWhenAuthenticationIsRequiredAction,
RedirectWhenTokenExpiredAction, SetRedirectUrlAction RedirectWhenTokenExpiredAction, SetRedirectUrlAction
@@ -153,6 +154,11 @@ export function authReducer(state: any = initialState, action: AuthActions): Aut
refreshing: false, refreshing: false,
}); });
case AuthActionTypes.ADD_MESSAGE:
return Object.assign({}, state, {
info: (action as AddAuthenticationMessageAction).payload,
});
case AuthActionTypes.RESET_MESSAGES: case AuthActionTypes.RESET_MESSAGES:
return Object.assign({}, state, { return Object.assign({}, state, {
authenticated: state.authenticated, authenticated: state.authenticated,