From d6806bd560d402f294462ba05428f5e9fe223734 Mon Sep 17 00:00:00 2001 From: Amedeo Lepore Date: Fri, 17 Mar 2023 18:33:22 +0100 Subject: [PATCH] [AAE-12501] Trigger on login when token is received --- .../src/lib/common/services/discovery-api.service.ts | 5 ++--- lib/core/src/lib/auth/oidc/oidc-authentication.service.ts | 7 +++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/content-services/src/lib/common/services/discovery-api.service.ts b/lib/content-services/src/lib/common/services/discovery-api.service.ts index 07695ca06d..52e7b87fe8 100644 --- a/lib/content-services/src/lib/common/services/discovery-api.service.ts +++ b/lib/content-services/src/lib/common/services/discovery-api.service.ts @@ -20,7 +20,7 @@ import { from, Observable, throwError, Subject } from 'rxjs'; import { catchError, map, switchMap, filter, take } from 'rxjs/operators'; import { RepositoryInfo, SystemPropertiesRepresentation } from '@alfresco/js-api'; -import { BpmProductVersionModel, AlfrescoApiService, AuthenticationService } from '@alfresco/adf-core'; +import { BpmProductVersionModel, AuthenticationService } from '@alfresco/adf-core'; import { ApiClientsService } from '@alfresco/adf-core/api'; @Injectable({ @@ -34,13 +34,12 @@ export class DiscoveryApiService { ecmProductInfo$ = new Subject(); constructor( - private apiService: AlfrescoApiService, private authenticationService: AuthenticationService, private apiClientsService: ApiClientsService ) { this.authenticationService.onLogin .pipe( - filter(() => this.apiService.getInstance()?.isEcmLoggedIn()), + filter(() => this.authenticationService.isEcmLoggedIn()), take(1), switchMap(() => this.getEcmProductInfo()) ) diff --git a/lib/core/src/lib/auth/oidc/oidc-authentication.service.ts b/lib/core/src/lib/auth/oidc/oidc-authentication.service.ts index ee400af07e..944260410d 100644 --- a/lib/core/src/lib/auth/oidc/oidc-authentication.service.ts +++ b/lib/core/src/lib/auth/oidc/oidc-authentication.service.ts @@ -46,6 +46,13 @@ export class OIDCAuthenticationService extends BaseAuthenticationService { private readonly auth: AuthService ) { super(alfrescoApi, appConfig, cookie, logService); + this.alfrescoApi.alfrescoApiInitialized.subscribe(() => { + this.oauthService.events.pipe( + filter((event)=> event.type === 'token_received') + ).subscribe(()=>{ + this.onLogin.next(); + }); + }); } isEcmLoggedIn(): boolean {