Skip to content

Commit d8ee1f5

Browse files
committed
closing auth check subscription
1 parent 0bf095a commit d8ee1f5

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/modules/app/browser-init.service.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ import { isNotEmpty } from '../../app/shared/empty.util';
3131
import { logStartupMessage } from '../../../startup-message';
3232
import { MenuService } from '../../app/shared/menu/menu.service';
3333
import { RootDataService } from '../../app/core/data/root-data.service';
34+
import { firstValueFrom, Subscription } from 'rxjs';
3435

3536
/**
3637
* Performs client-side initialization.
3738
*/
3839
@Injectable()
3940
export 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

Comments
 (0)