force initservices to wait until authentication is no longer blocking

This commit is contained in:
Art Lowel
2022-08-23 17:50:46 +02:00
parent ca87f09625
commit 4b20b0cb81
4 changed files with 46 additions and 16 deletions

View File

@@ -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;
};
}