@@ -31,12 +31,16 @@ import { isNotEmpty } from '../../app/shared/empty.util';
3131import { logStartupMessage } from '../../../startup-message' ;
3232import { MenuService } from '../../app/shared/menu/menu.service' ;
3333import { RootDataService } from '../../app/core/data/root-data.service' ;
34+ import { firstValueFrom , Subscription } from 'rxjs' ;
3435
3536/**
3637 * Performs client-side initialization.
3738 */
3839@Injectable ( )
3940export class BrowserInitService extends InitService {
41+
42+ sub : Subscription ;
43+
4044 constructor (
4145 protected store : Store < AppState > ,
4246 protected correlationIdService : CorrelationIdService ,
@@ -139,13 +143,13 @@ export class BrowserInitService extends InitService {
139143 }
140144
141145 /**
142- * During the external authentication flow invalidates the SSR transferState
146+ * During an external authentication flow invalidate the SSR transferState
143147 * data in the cache. This allows the app to fetch fresh content.
144148 * @private
145149 */
146150 private externalAuthCheck ( ) {
147151
148- this . authService . isExternalAuthentication ( ) . pipe (
152+ this . sub = this . authService . isExternalAuthentication ( ) . pipe (
149153 filter ( ( externalAuth : boolean ) => externalAuth )
150154 ) . subscribe ( ( ) => {
151155 // Clear the transferState data.
@@ -154,6 +158,19 @@ export class BrowserInitService extends InitService {
154158 }
155159 ) ;
156160
161+ this . closeAuthCheckSubscription ( ) ;
162+ }
163+
164+ /**
165+ * Unsubscribe the external authentication subscription
166+ * when authentication is no longer blocking.
167+ * @private
168+ */
169+ private closeAuthCheckSubscription ( ) {
170+ firstValueFrom ( this . authenticationReady$ ( ) ) . then ( ( ) => {
171+ this . sub . unsubscribe ( ) ;
172+ }
173+ )
157174 }
158175
159176}
0 commit comments