Skip to content

Commit

Permalink
Fix C280012: set app prefix before calling content api
Browse files Browse the repository at this point in the history
  • Loading branch information
alep85 committed Jul 21, 2023
1 parent afbf086 commit 6b74bb1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
10 changes: 10 additions & 0 deletions lib/core/src/lib/app-config/app-config.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,14 @@ describe('AppConfigService', () => {

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();
});

});
6 changes: 3 additions & 3 deletions lib/core/src/lib/app-config/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ export class AppConfigService {
this.onLoadSubject.next(this.config);
}

protected onDataLoaded(data: any) {
this.config = Object.assign({}, this.config, data || {});
protected onDataLoaded() {
this.onLoadSubject.next(this.config);

this.extensionService.setup$
Expand Down Expand Up @@ -198,9 +197,10 @@ export class AppConfigService {
this.http.get(configUrl).subscribe(
(data: any) => {
this.status = Status.LOADED;
this.config = Object.assign({}, this.config, data || {});
callback?.();
resolve(data);
this.onDataLoaded(data);
this.onDataLoaded();
},
() => {
// eslint-disable-next-line no-console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@
* 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 { Authentication } from '../interfaces/authentication.interface';
import { CookieService } from '../../common/services/cookie.service';
import { ContentAuth } from './content-auth';
import { ProcessAuth } from './process-auth';
import { catchError, map } from 'rxjs/operators';
import { from, Observable, zip } from 'rxjs';
import { from, Observable } from 'rxjs';
import { RedirectionModel } from '../models/redirection.model';
import { BaseAuthenticationService } from '../services/base-authentication.service';
import { LogService } from '../../common';
import { HttpHeaders } from '@angular/common/http';
import { AlfrescoApiService } from '../../../..';

const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME';
const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30;
Expand All @@ -36,7 +35,6 @@ const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30;
providedIn: 'root'
})
export class BasicAlfrescoAuthService extends BaseAuthenticationService {
alfrescoApiService = inject(AlfrescoApiService);

protected redirectUrl: RedirectionModel = null;

Expand All @@ -56,7 +54,7 @@ export class BasicAlfrescoAuthService extends BaseAuthenticationService {
) {
super(appConfig, cookie, logService);

zip(this.alfrescoApiService.alfrescoApiInitialized, this.appConfig.onLoad)
this.appConfig.onLoad
.subscribe(() => {
if (this.isLoggedIn()) {
this.onLogin.next('logged-in');
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/lib/common/mock/app-config.service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class AppConfigServiceMock extends AppConfigService {
load(): Promise<any> {
return new Promise((resolve) => {
this.status = Status.LOADED;
this.onDataLoaded(this.config);
this.onDataLoaded();
resolve(this.config);
});
}
Expand Down

0 comments on commit 6b74bb1

Please sign in to comment.