From 796243596647ca479be0d44f87abb03102fd0a82 Mon Sep 17 00:00:00 2001 From: eromano Date: Wed, 26 Jul 2023 17:19:34 +0200 Subject: [PATCH] fix --- lib/core/src/lib/app-config/app-config.service.ts | 6 +++--- .../src/lib/auth/services/oidc-authentication.service.ts | 5 +++-- lib/core/src/lib/testing/automation.service.ts | 5 ----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/core/src/lib/app-config/app-config.service.ts b/lib/core/src/lib/app-config/app-config.service.ts index 7b570471e1..e7c6915b30 100644 --- a/lib/core/src/lib/app-config/app-config.service.ts +++ b/lib/core/src/lib/app-config/app-config.service.ts @@ -18,7 +18,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { ObjectUtils } from '../common/utils/object-utils'; -import { Observable, Subject } from 'rxjs'; +import { Observable, ReplaySubject } from 'rxjs'; import { map, distinctUntilChanged, take } from 'rxjs/operators'; import { ExtensionConfig, ExtensionService, mergeObjects } from '@alfresco/adf-extensions'; import { OpenidConfiguration } from '../auth/interfaces/openid-configuration.interface'; @@ -72,7 +72,7 @@ export class AppConfigService { }; status: Status = Status.INIT; - protected onLoadSubject: Subject; + protected onLoadSubject: ReplaySubject; onLoad: Observable; get isLoaded() { @@ -80,7 +80,7 @@ export class AppConfigService { } constructor(protected http: HttpClient, protected extensionService: ExtensionService) { - this.onLoadSubject = new Subject(); + this.onLoadSubject = new ReplaySubject(); this.onLoad = this.onLoadSubject.asObservable(); extensionService.setup$.subscribe((config) => { diff --git a/lib/core/src/lib/auth/services/oidc-authentication.service.ts b/lib/core/src/lib/auth/services/oidc-authentication.service.ts index 366895bd08..7f1aafe983 100644 --- a/lib/core/src/lib/auth/services/oidc-authentication.service.ts +++ b/lib/core/src/lib/auth/services/oidc-authentication.service.ts @@ -99,16 +99,17 @@ export class OidcAuthenticationService extends BaseAuthenticationService { } loginWithPassword(username: string, password: string): Observable<{ type: string; ticket: any }> { - // @ts-ignore return defer(async () => { try { + await this.authConfig.loadConfig(); + await this.oauthService.loadDiscoveryDocument(); await this.oauthService.fetchTokenUsingPasswordFlowAndLoadUserProfile(username, password); await this.oauthService.refreshToken(); const accessToken = this.oauthService.getAccessToken(); this.onLogin.next(accessToken); return { - type: this.appConfig.get(AppConfigValues.PROVIDERS), + type: this.appConfig.get(AppConfigValues.PROVIDERS), ticket: accessToken }; } catch (err) { diff --git a/lib/core/src/lib/testing/automation.service.ts b/lib/core/src/lib/testing/automation.service.ts index ebf711f347..33acfba051 100644 --- a/lib/core/src/lib/testing/automation.service.ts +++ b/lib/core/src/lib/testing/automation.service.ts @@ -37,14 +37,9 @@ export class CoreAutomationService { private storageService: StorageService, private auth: AuthenticationService ) { - // eslint-disable-next-line no-console - console.log('ADF Core AutomationService init'); } setup() { - // eslint-disable-next-line no-console - console.log('ADF Core setup'); - const adfProxy = window['adf'] || {}; adfProxy.getConfigField = (field: string): any => this.appConfigService.get(field);