This commit is contained in:
eromano
2023-08-31 10:27:07 +02:00
parent 8814b0b95c
commit 7962435966
3 changed files with 6 additions and 10 deletions
@@ -18,7 +18,7 @@
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ObjectUtils } from '../common/utils/object-utils'; 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 { map, distinctUntilChanged, take } from 'rxjs/operators';
import { ExtensionConfig, ExtensionService, mergeObjects } from '@alfresco/adf-extensions'; import { ExtensionConfig, ExtensionService, mergeObjects } from '@alfresco/adf-extensions';
import { OpenidConfiguration } from '../auth/interfaces/openid-configuration.interface'; import { OpenidConfiguration } from '../auth/interfaces/openid-configuration.interface';
@@ -72,7 +72,7 @@ export class AppConfigService {
}; };
status: Status = Status.INIT; status: Status = Status.INIT;
protected onLoadSubject: Subject<any>; protected onLoadSubject: ReplaySubject<any>;
onLoad: Observable<any>; onLoad: Observable<any>;
get isLoaded() { get isLoaded() {
@@ -80,7 +80,7 @@ export class AppConfigService {
} }
constructor(protected http: HttpClient, protected extensionService: ExtensionService) { constructor(protected http: HttpClient, protected extensionService: ExtensionService) {
this.onLoadSubject = new Subject(); this.onLoadSubject = new ReplaySubject();
this.onLoad = this.onLoadSubject.asObservable(); this.onLoad = this.onLoadSubject.asObservable();
extensionService.setup$.subscribe((config) => { extensionService.setup$.subscribe((config) => {
@@ -99,16 +99,17 @@ export class OidcAuthenticationService extends BaseAuthenticationService {
} }
loginWithPassword(username: string, password: string): Observable<{ type: string; ticket: any }> { loginWithPassword(username: string, password: string): Observable<{ type: string; ticket: any }> {
// @ts-ignore
return defer(async () => { return defer(async () => {
try { try {
await this.authConfig.loadConfig();
await this.oauthService.loadDiscoveryDocument();
await this.oauthService.fetchTokenUsingPasswordFlowAndLoadUserProfile(username, password); await this.oauthService.fetchTokenUsingPasswordFlowAndLoadUserProfile(username, password);
await this.oauthService.refreshToken(); await this.oauthService.refreshToken();
const accessToken = this.oauthService.getAccessToken(); const accessToken = this.oauthService.getAccessToken();
this.onLogin.next(accessToken); this.onLogin.next(accessToken);
return { return {
type: this.appConfig.get(AppConfigValues.PROVIDERS), type: <string>this.appConfig.get(AppConfigValues.PROVIDERS),
ticket: accessToken ticket: accessToken
}; };
} catch (err) { } catch (err) {
@@ -37,14 +37,9 @@ export class CoreAutomationService {
private storageService: StorageService, private storageService: StorageService,
private auth: AuthenticationService private auth: AuthenticationService
) { ) {
// eslint-disable-next-line no-console
console.log('ADF Core AutomationService init');
} }
setup() { setup() {
// eslint-disable-next-line no-console
console.log('ADF Core setup');
const adfProxy = window['adf'] || {}; const adfProxy = window['adf'] || {};
adfProxy.getConfigField = (field: string): any => this.appConfigService.get(field); adfProxy.getConfigField = (field: string): any => this.appConfigService.get(field);