From 0ad4bf6eb954e5a62246a1736e315981e99fff4a Mon Sep 17 00:00:00 2001 From: Vito Date: Thu, 25 Jan 2018 17:54:43 +0100 Subject: [PATCH] [ADF-2200] fixed redirectUrl check (#2886) --- .../services/authentication.service.spec.ts | 18 ++++++++++++++++++ lib/core/services/authentication.service.ts | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/core/services/authentication.service.spec.ts b/lib/core/services/authentication.service.spec.ts index 8f9e49efec..4f25dd591c 100644 --- a/lib/core/services/authentication.service.spec.ts +++ b/lib/core/services/authentication.service.spec.ts @@ -270,6 +270,12 @@ describe('AuthenticationService', () => { expect(authService.getRedirectUrl(preferences.authType)).toBeNull(); }); + + it('[ECM] should return null as redirectUrl when redirectUrl field is not set', () => { + authService.setRedirectUrl( null ); + + expect(authService.getRedirectUrl(preferences.authType)).toBeNull(); + }); }); describe('when the setting is BPM', () => { @@ -391,6 +397,12 @@ describe('AuthenticationService', () => { expect(authService.getRedirectUrl(preferences.authType)).toBeNull(); }); + + it('[BPM] should return null as redirectUrl when redirectUrl field is not set', () => { + authService.setRedirectUrl( null ); + + expect(authService.getRedirectUrl(preferences.authType)).toBeNull(); + }); }); describe('when the setting is both ECM and BPM ', () => { @@ -503,6 +515,12 @@ describe('AuthenticationService', () => { expect(authService.getRedirectUrl(preferences.authType)).toBe('some-url'); }); + + it('[ALL] should return null as redirectUrl when redirectUrl field is not set', () => { + authService.setRedirectUrl( null ); + + expect(authService.getRedirectUrl(preferences.authType)).toBeNull(); + }); }); }); diff --git a/lib/core/services/authentication.service.ts b/lib/core/services/authentication.service.ts index 30b7eee641..5c4821b6cc 100644 --- a/lib/core/services/authentication.service.ts +++ b/lib/core/services/authentication.service.ts @@ -239,15 +239,15 @@ export class AuthenticationService { } getRedirectUrl(provider: string): string { - return this.hasValidRedirection(provider) ? this.redirectUrl.url : null; + return this.hasValidRedirection(provider) ? this.redirectUrl.url : null; } private hasValidRedirection(provider: string): boolean { - return this.redirectUrl && this.redirectUrl.provider === provider || this.hasSelectedProviderAll(provider); + return this.redirectUrl && (this.redirectUrl.provider === provider || this.hasSelectedProviderAll(provider)); } private hasSelectedProviderAll(provider: string): boolean { - return this.redirectUrl && this.redirectUrl.provider === 'ALL' || provider === 'ALL'; + return this.redirectUrl && (this.redirectUrl.provider === 'ALL' || provider === 'ALL'); } /**