mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
force initservices to wait until authentication is no longer blocking
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
import { InitService } from '../../app/init.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Store, select } from '@ngrx/store';
|
||||
import { AppState } from '../../app/app.reducer';
|
||||
import { TransferState } from '@angular/platform-browser';
|
||||
import { CorrelationIdService } from '../../app/correlation-id/correlation-id.service';
|
||||
@@ -20,7 +20,8 @@ import { MetadataService } from '../../app/core/metadata/metadata.service';
|
||||
import { BreadcrumbsService } from '../../app/breadcrumbs/breadcrumbs.service';
|
||||
import { CSSVariableService } from '../../app/shared/sass-helper/sass-helper.service';
|
||||
import { ThemeService } from '../../app/shared/theme-support/theme.service';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { take, distinctUntilChanged, find } from 'rxjs/operators';
|
||||
import { isAuthenticationBlocking } from '../../app/core/auth/selectors';
|
||||
|
||||
/**
|
||||
* Performs server-side initialization.
|
||||
@@ -66,6 +67,13 @@ export class ServerInitService extends InitService {
|
||||
this.initRouteListeners();
|
||||
this.themeService.listenForThemeChanges(false);
|
||||
|
||||
// wait for auth to be ready
|
||||
await this.store.pipe(
|
||||
select(isAuthenticationBlocking),
|
||||
distinctUntilChanged(),
|
||||
find((b: boolean) => b === false)
|
||||
).toPromise();
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user