Fix C280012: set app prefix before calling content api

This commit is contained in:
Amedeo Lepore
2023-08-31 10:27:07 +02:00
committed by eromano
parent fa4e71781b
commit b777d3ec9d
4 changed files with 17 additions and 9 deletions
@@ -188,4 +188,14 @@ describe('AppConfigService', () => {
expect(appConfigService.get('files.excluded')[0]).toBe('excluded'); expect(appConfigService.get('files.excluded')[0]).toBe('excluded');
}); });
it('should execute callback function if is passed to the load method', async () => {
const fakeCallBack = jasmine.createSpy('fakeCallBack');
fakeCallBack.and.returnValue(()=>{});
await appConfigService.load(fakeCallBack);
expect(fakeCallBack).toHaveBeenCalled();
});
}); });
@@ -165,8 +165,7 @@ export class AppConfigService {
this.onLoadSubject.next(this.config); this.onLoadSubject.next(this.config);
} }
protected onDataLoaded(data: any) { protected onDataLoaded() {
this.config = Object.assign({}, this.config, data || {});
this.onLoadSubject.next(this.config); this.onLoadSubject.next(this.config);
this.extensionService.setup$ this.extensionService.setup$
@@ -198,9 +197,10 @@ 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;
this.config = Object.assign({}, this.config, data || {});
callback?.(); callback?.();
resolve(data); resolve(data);
this.onDataLoaded(data); this.onDataLoaded();
}, },
() => { () => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
@@ -15,19 +15,18 @@
* limitations under the License. * limitations under the License.
*/ */
import { Injectable, inject } from '@angular/core'; import { Injectable } 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, zip } from 'rxjs'; import { from, Observable } 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;
@@ -36,7 +35,6 @@ 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;
@@ -56,7 +54,7 @@ export class BasicAlfrescoAuthService extends BaseAuthenticationService {
) { ) {
super(appConfig, cookie, logService); super(appConfig, cookie, logService);
zip(this.alfrescoApiService.alfrescoApiInitialized, this.appConfig.onLoad) this.appConfig.onLoad
.subscribe(() => { .subscribe(() => {
if (this.isLoggedIn()) { if (this.isLoggedIn()) {
this.onLogin.next('logged-in'); this.onLogin.next('logged-in');
@@ -38,7 +38,7 @@ export class AppConfigServiceMock extends AppConfigService {
load(): Promise<any> { load(): Promise<any> {
return new Promise((resolve) => { return new Promise((resolve) => {
this.status = Status.LOADED; this.status = Status.LOADED;
this.onDataLoaded(this.config); this.onDataLoaded();
resolve(this.config); resolve(this.config);
}); });
} }