mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Added action to retrieve authenticated eperson object
This commit is contained in:
@@ -26,7 +26,10 @@ import {
|
||||
RefreshTokenSuccessAction,
|
||||
RegistrationAction,
|
||||
RegistrationErrorAction,
|
||||
RegistrationSuccessAction
|
||||
RegistrationSuccessAction,
|
||||
RetrieveAuthenticatedEpersonAction,
|
||||
RetrieveAuthenticatedEpersonErrorAction,
|
||||
RetrieveAuthenticatedEpersonSuccessAction
|
||||
} from './auth.actions';
|
||||
import { EPerson } from '../eperson/models/eperson.model';
|
||||
import { AuthStatus } from './models/auth-status.model';
|
||||
@@ -66,11 +69,17 @@ export class AuthEffects {
|
||||
ofType(AuthActionTypes.AUTHENTICATED),
|
||||
switchMap((action: AuthenticatedAction) => {
|
||||
return this.authService.authenticatedUser(action.payload).pipe(
|
||||
map((user: EPerson) => new AuthenticatedSuccessAction((user !== null), action.payload, user)),
|
||||
map((userHref: string) => new AuthenticatedSuccessAction((userHref !== null), action.payload, userHref)),
|
||||
catchError((error) => observableOf(new AuthenticatedErrorAction(error))),);
|
||||
})
|
||||
);
|
||||
|
||||
@Effect()
|
||||
public authenticatedSuccess$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(AuthActionTypes.AUTHENTICATED_SUCCESS),
|
||||
map((action: AuthenticatedSuccessAction) => new RetrieveAuthenticatedEpersonAction(action.payload.userHref))
|
||||
);
|
||||
|
||||
// It means "reacts to this action but don't send another"
|
||||
@Effect({ dispatch: false })
|
||||
public authenticatedError$: Observable<Action> = this.actions$.pipe(
|
||||
@@ -78,6 +87,16 @@ export class AuthEffects {
|
||||
tap((action: LogOutSuccessAction) => this.authService.removeToken())
|
||||
);
|
||||
|
||||
@Effect()
|
||||
public retrieveAuthenticatedEperson$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(AuthActionTypes.RETRIEVE_AUTHENTICATED_EPERSON),
|
||||
switchMap((action: RetrieveAuthenticatedEpersonAction) => {
|
||||
return this.authService.retrieveAuthenticatedUserByHref(action.payload).pipe(
|
||||
map((user: EPerson) => new RetrieveAuthenticatedEpersonSuccessAction(user)),
|
||||
catchError((error) => observableOf(new RetrieveAuthenticatedEpersonErrorAction(error))));
|
||||
})
|
||||
);
|
||||
|
||||
@Effect()
|
||||
public checkToken$: Observable<Action> = this.actions$.pipe(ofType(AuthActionTypes.CHECK_AUTHENTICATION_TOKEN),
|
||||
switchMap(() => {
|
||||
|
Reference in New Issue
Block a user