[ADF-2200] fixed redirectUrl check (#2886)

This commit is contained in:
Vito 2018-01-25 17:54:43 +01:00 committed by Eugenio Romano
parent 657c28491a
commit 0ad4bf6eb9
2 changed files with 21 additions and 3 deletions

View File

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

View File

@ -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');
}
/**