mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-26 17:24:45 +00:00
[ACA-2133] fix application ready event for kerberos (#1002)
* fix application ready event for kerberos * format file * spellcheck fixes
This commit is contained in:
parent
92a5ec44e8
commit
9157d50974
@ -2,6 +2,7 @@
|
||||
"version": "0.1",
|
||||
"language": "en",
|
||||
"words": [
|
||||
"Kerberos",
|
||||
"succes",
|
||||
"sharedlinks",
|
||||
"Redistributable",
|
||||
|
@ -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 () => {
|
||||
|
@ -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,20 @@ export class AppService {
|
||||
private ready: BehaviorSubject<boolean>;
|
||||
ready$: Observable<boolean>;
|
||||
|
||||
/**
|
||||
* Whether `withCredentials` mode is enabled.
|
||||
* Usually means that `Kerberos` mode is used.
|
||||
*/
|
||||
get withCredentials(): boolean {
|
||||
return this.config.get<boolean>('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(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user