[AAE-12501] Trigger on login when token is received

This commit is contained in:
Amedeo Lepore
2023-03-31 12:12:03 +02:00
parent 2a2e3c4eca
commit d6806bd560
2 changed files with 9 additions and 3 deletions
@@ -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<RepositoryInfo>();
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())
)
@@ -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 {