mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Fixed issue with authentication when SSR is disabled
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
|
||||
import { catchError, debounceTime, filter, map, switchMap, take, tap } from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
|
||||
import { catchError, debounceTime, filter, map, switchMap, take, tap } from 'rxjs/operators';
|
||||
// import @ngrx
|
||||
import { Actions, Effect, ofType } from '@ngrx/effects';
|
||||
import { Action, select, Store } from '@ngrx/store';
|
||||
|
||||
// import services
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
import { EPerson } from '../eperson/models/eperson.model';
|
||||
import { AuthStatus } from './models/auth-status.model';
|
||||
import { AuthTokenInfo } from './models/auth-token-info.model';
|
||||
import { AppState } from '../../app.reducer';
|
||||
import { isAuthenticated } from './selectors';
|
||||
import { isAuthenticated, isAuthenticatedLoaded } from './selectors';
|
||||
import { StoreActionTypes } from '../../store.actions';
|
||||
import { AuthMethod } from './models/auth.method';
|
||||
// import actions
|
||||
@@ -187,10 +185,11 @@ export class AuthEffects {
|
||||
public clearInvalidTokenOnRehydrate$: Observable<any> = this.actions$.pipe(
|
||||
ofType(StoreActionTypes.REHYDRATE),
|
||||
switchMap(() => {
|
||||
return this.store.pipe(
|
||||
select(isAuthenticated),
|
||||
const isLoaded$ = this.store.pipe(select(isAuthenticatedLoaded));
|
||||
const authenticated$ = this.store.pipe(select(isAuthenticated));
|
||||
return observableCombineLatest(isLoaded$, authenticated$).pipe(
|
||||
take(1),
|
||||
filter((authenticated) => !authenticated),
|
||||
filter(([loaded, authenticated]) => loaded && !authenticated),
|
||||
tap(() => this.authService.removeToken()),
|
||||
tap(() => this.authService.resetAuthenticationError())
|
||||
);
|
||||
|
Reference in New Issue
Block a user