From bda9116380e1c864f940a89e584c1a374f625a3a Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 7 Mar 2019 07:24:04 +0000 Subject: [PATCH 1/3] fix application ready event for kerberos --- src/app/services/app.service.spec.ts | 21 +++++++++++++++++++-- src/app/services/app.service.ts | 16 ++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/app/services/app.service.spec.ts b/src/app/services/app.service.spec.ts index 442b9bfdc1..464b7c20fe 100644 --- a/src/app/services/app.service.spec.ts +++ b/src/app/services/app.service.spec.ts @@ -26,7 +26,7 @@ import { AppService } from './app.service'; import { TestBed } from '@angular/core/testing'; import { AppTestingModule } from '../testing/app-testing.module'; -import { AuthenticationService } from '@alfresco/adf-core'; +import { AuthenticationService, AppConfigService } from '@alfresco/adf-core'; import { AppRouteReuseStrategy } from '../app.routes.strategy'; import { Subject } from 'rxjs'; @@ -34,6 +34,7 @@ describe('AppService', () => { let service: AppService; let auth: AuthenticationService; let routeReuse: AppRouteReuseStrategy; + let appConfig: AppConfigService; beforeEach(() => { TestBed.configureTestingModule({ @@ -53,9 +54,25 @@ describe('AppService', () => { routeReuse = TestBed.get(AppRouteReuseStrategy); auth = TestBed.get(AuthenticationService); + appConfig = TestBed.get(AppConfigService); spyOn(routeReuse, 'resetCache').and.stub(); - service = new AppService(auth, routeReuse); + service = new AppService(auth, appConfig, routeReuse); + }); + + it('should be ready if [withCredentials] mode is used', done => { + appConfig.config = { + auth: { + withCredentials: true + } + }; + + const instance = new AppService(auth, appConfig, routeReuse); + expect(instance.withCredentials).toBeTruthy(); + + instance.ready$.subscribe(() => { + done(); + }); }); it('should reset route cache on login', async () => { diff --git a/src/app/services/app.service.ts b/src/app/services/app.service.ts index 259f972b13..e26881f985 100644 --- a/src/app/services/app.service.ts +++ b/src/app/services/app.service.ts @@ -24,7 +24,7 @@ */ import { Injectable, Inject } from '@angular/core'; -import { AuthenticationService } from '@alfresco/adf-core'; +import { AuthenticationService, AppConfigService } from '@alfresco/adf-core'; import { Observable, BehaviorSubject } from 'rxjs'; import { AppRouteReuseStrategy } from '../app.routes.strategy'; import { RouteReuseStrategy } from '@angular/router'; @@ -36,11 +36,23 @@ export class AppService { private ready: BehaviorSubject; ready$: Observable; + /** + * Whether `withCredentials` mode is enabled. + * Usually means that `Kerberos` mode is used. + */ + get withCredentials(): boolean { + return this.config.get( + 'auth.withCredentials', + false + ); + } + constructor( auth: AuthenticationService, + private config: AppConfigService, @Inject(RouteReuseStrategy) routeStrategy: AppRouteReuseStrategy ) { - this.ready = new BehaviorSubject(auth.isLoggedIn()); + this.ready = new BehaviorSubject(auth.isLoggedIn() || this.withCredentials); this.ready$ = this.ready.asObservable(); auth.onLogin.subscribe(() => { From 0da25930fcaad6f35c1332994504bd1b7a53640c Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 7 Mar 2019 07:24:46 +0000 Subject: [PATCH 2/3] format file --- src/app/services/app.service.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/app/services/app.service.ts b/src/app/services/app.service.ts index e26881f985..99aca6732e 100644 --- a/src/app/services/app.service.ts +++ b/src/app/services/app.service.ts @@ -41,10 +41,7 @@ export class AppService { * Usually means that `Kerberos` mode is used. */ get withCredentials(): boolean { - return this.config.get( - 'auth.withCredentials', - false - ); + return this.config.get('auth.withCredentials', false); } constructor( From 95c0faf18ede73c6343451b412873831273c8c7f Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 7 Mar 2019 07:37:46 +0000 Subject: [PATCH 3/3] spellcheck fixes --- cspell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/cspell.json b/cspell.json index ecc4c0ed8f..64b6b0b898 100644 --- a/cspell.json +++ b/cspell.json @@ -2,6 +2,7 @@ "version": "0.1", "language": "en", "words": [ + "Kerberos", "succes", "sharedlinks", "Redistributable",