Fix prefix is undefined

This commit is contained in:
Amedeo Lepore
2023-07-18 18:36:06 +02:00
committed by eromano
parent 1bdd398916
commit 7bbfa6bfec
3 changed files with 16 additions and 11 deletions

View File

@@ -20,8 +20,9 @@ import { StorageService } from '../common/services/storage.service';
import { AdfHttpClient } from '@alfresco/adf-core/api'; import { AdfHttpClient } from '@alfresco/adf-core/api';
export function loadAppConfig(appConfigService: AppConfigService, storageService: StorageService, adfHttpClient: AdfHttpClient) { export function loadAppConfig(appConfigService: AppConfigService, storageService: StorageService, adfHttpClient: AdfHttpClient) {
return () => appConfigService.load().then(() => { const init = () => {
adfHttpClient.disableCsrf = appConfigService.get<boolean>(AppConfigValues.DISABLECSRF, true); adfHttpClient.disableCsrf = appConfigService.get<boolean>(AppConfigValues.DISABLECSRF, true);
storageService.prefix = appConfigService.get<string>(AppConfigValues.STORAGE_PREFIX, ''); storageService.prefix = appConfigService.get<string>(AppConfigValues.STORAGE_PREFIX, '');
}); };
} return () => appConfigService.load(init);
};

View File

@@ -189,7 +189,7 @@ export class AppConfigService {
* *
* @returns Notification when loading is complete * @returns Notification when loading is complete
*/ */
load(): Promise<any> { load(callback?: (...args: any[]) => any): Promise<any> {
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
const configUrl = `app.config.json?v=${Date.now()}`; const configUrl = `app.config.json?v=${Date.now()}`;
@@ -198,6 +198,7 @@ export class AppConfigService {
this.http.get(configUrl).subscribe( this.http.get(configUrl).subscribe(
(data: any) => { (data: any) => {
this.status = Status.LOADED; this.status = Status.LOADED;
callback?.();
resolve(data); resolve(data);
this.onDataLoaded(data); this.onDataLoaded(data);
}, },

View File

@@ -15,18 +15,19 @@
* limitations under the License. * limitations under the License.
*/ */
import { Injectable } from '@angular/core'; import { Injectable, inject } from '@angular/core';
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service'; import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
import { Authentication } from '../interfaces/authentication.interface'; import { Authentication } from '../interfaces/authentication.interface';
import { CookieService } from '../../common/services/cookie.service'; import { CookieService } from '../../common/services/cookie.service';
import { ContentAuth } from './content-auth'; import { ContentAuth } from './content-auth';
import { ProcessAuth } from './process-auth'; import { ProcessAuth } from './process-auth';
import { catchError, map } from 'rxjs/operators'; import { catchError, map } from 'rxjs/operators';
import { from, Observable } from 'rxjs'; import { from, Observable, zip } from 'rxjs';
import { RedirectionModel } from '../models/redirection.model'; import { RedirectionModel } from '../models/redirection.model';
import { BaseAuthenticationService } from '../services/base-authentication.service'; import { BaseAuthenticationService } from '../services/base-authentication.service';
import { LogService } from '../../common'; import { LogService } from '../../common';
import { HttpHeaders } from '@angular/common/http'; import { HttpHeaders } from '@angular/common/http';
import { AlfrescoApiService } from '../../../..';
const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME'; const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME';
const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30; const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30;
@@ -35,6 +36,7 @@ const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30;
providedIn: 'root' providedIn: 'root'
}) })
export class BasicAlfrescoAuthService extends BaseAuthenticationService { export class BasicAlfrescoAuthService extends BaseAuthenticationService {
alfrescoApiService = inject(AlfrescoApiService);
protected redirectUrl: RedirectionModel = null; protected redirectUrl: RedirectionModel = null;
@@ -54,7 +56,8 @@ export class BasicAlfrescoAuthService extends BaseAuthenticationService {
) { ) {
super(appConfig, cookie, logService); super(appConfig, cookie, logService);
this.appConfig.onLoad.subscribe(() => { zip(this.alfrescoApiService.alfrescoApiInitialized, this.appConfig.onLoad)
.subscribe(() => {
if (this.isLoggedIn()) { if (this.isLoggedIn()) {
this.onLogin.next('logged-in'); this.onLogin.next('logged-in');
} }