mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 18:44:14 +00:00
Added auth action that allows to retrieve token once check on authentication cooke is successful
This commit is contained in:
@@ -27,7 +27,7 @@ import {
|
||||
RegistrationSuccessAction,
|
||||
RetrieveAuthMethodsAction,
|
||||
RetrieveAuthMethodsErrorAction,
|
||||
RetrieveAuthMethodsSuccessAction
|
||||
RetrieveAuthMethodsSuccessAction, RetrieveTokenAction
|
||||
} from './auth.actions';
|
||||
import { EPerson } from '../eperson/models/eperson.model';
|
||||
import { AuthStatus } from './models/auth-status.model';
|
||||
@@ -97,7 +97,7 @@ export class AuthEffects {
|
||||
return this.authService.checkAuthenticationCookie().pipe(
|
||||
map((response: AuthStatus) => {
|
||||
if (response.authenticated) {
|
||||
return new RefreshTokenAction(null);
|
||||
return new RetrieveTokenAction();
|
||||
} else {
|
||||
return new RetrieveAuthMethodsAction(response);
|
||||
}
|
||||
@@ -119,6 +119,18 @@ export class AuthEffects {
|
||||
})
|
||||
);
|
||||
|
||||
@Effect()
|
||||
public retrieveToken$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(AuthActionTypes.RETRIEVE_TOKEN),
|
||||
switchMap((action: AuthenticateAction) => {
|
||||
return this.authService.refreshAuthenticationToken(null).pipe(
|
||||
take(1),
|
||||
map((token: AuthTokenInfo) => new AuthenticationSuccessAction(token)),
|
||||
catchError((error) => observableOf(new AuthenticationErrorAction(error)))
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
@Effect()
|
||||
public refreshToken$: Observable<Action> = this.actions$.pipe(ofType(AuthActionTypes.REFRESH_TOKEN),
|
||||
switchMap((action: RefreshTokenAction) => {
|
||||
|
Reference in New Issue
Block a user