mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
closing auth check subscription
This commit is contained in:

committed by
Michael W Spalti

parent
0bf095a1d9
commit
d8ee1f55f1
@@ -31,12 +31,16 @@ import { isNotEmpty } from '../../app/shared/empty.util';
|
|||||||
import { logStartupMessage } from '../../../startup-message';
|
import { logStartupMessage } from '../../../startup-message';
|
||||||
import { MenuService } from '../../app/shared/menu/menu.service';
|
import { MenuService } from '../../app/shared/menu/menu.service';
|
||||||
import { RootDataService } from '../../app/core/data/root-data.service';
|
import { RootDataService } from '../../app/core/data/root-data.service';
|
||||||
|
import { firstValueFrom, Subscription } from 'rxjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs client-side initialization.
|
* Performs client-side initialization.
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BrowserInitService extends InitService {
|
export class BrowserInitService extends InitService {
|
||||||
|
|
||||||
|
sub: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected store: Store<AppState>,
|
protected store: Store<AppState>,
|
||||||
protected correlationIdService: CorrelationIdService,
|
protected correlationIdService: CorrelationIdService,
|
||||||
@@ -139,13 +143,13 @@ export class BrowserInitService extends InitService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* During the external authentication flow invalidates the SSR transferState
|
* During an external authentication flow invalidate the SSR transferState
|
||||||
* data in the cache. This allows the app to fetch fresh content.
|
* data in the cache. This allows the app to fetch fresh content.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private externalAuthCheck() {
|
private externalAuthCheck() {
|
||||||
|
|
||||||
this.authService.isExternalAuthentication().pipe(
|
this.sub = this.authService.isExternalAuthentication().pipe(
|
||||||
filter((externalAuth: boolean) => externalAuth)
|
filter((externalAuth: boolean) => externalAuth)
|
||||||
).subscribe(() => {
|
).subscribe(() => {
|
||||||
// Clear the transferState data.
|
// Clear the transferState data.
|
||||||
@@ -154,6 +158,19 @@ export class BrowserInitService extends InitService {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.closeAuthCheckSubscription();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unsubscribe the external authentication subscription
|
||||||
|
* when authentication is no longer blocking.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
private closeAuthCheckSubscription() {
|
||||||
|
firstValueFrom(this.authenticationReady$()).then(() => {
|
||||||
|
this.sub.unsubscribe();
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user