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 { 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<any>;
protected onLoadSubject: ReplaySubject<any>;
onLoad: Observable<any>;
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) => {
@@ -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: <string>this.appConfig.get(AppConfigValues.PROVIDERS),
ticket: accessToken
};
} catch (err) {
@@ -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);