diff --git a/lib/core/services/authentication.service.spec.ts b/lib/core/services/authentication.service.spec.ts index d1ef145278..ef0ee38202 100644 --- a/lib/core/services/authentication.service.spec.ts +++ b/lib/core/services/authentication.service.spec.ts @@ -129,6 +129,7 @@ describe('AuthenticationService', () => { it('should require remember me set for ECM check', () => { spyOn(cookie, 'isEnabled').and.returnValue(true); spyOn(authService, 'isRememberMeSet').and.returnValue(false); + spyOn(authService, 'isECMProvider').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(false); spyOn(apiService, 'getInstance').and.callThrough(); @@ -139,6 +140,7 @@ describe('AuthenticationService', () => { it('should not require cookie service enabled for ECM check', () => { spyOn(cookie, 'isEnabled').and.returnValue(false); spyOn(authService, 'isRememberMeSet').and.returnValue(false); + spyOn(authService, 'isECMProvider').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(false); spyOn(apiService, 'getInstance').and.callThrough(); @@ -220,6 +222,22 @@ describe('AuthenticationService', () => { expect(authService.getRedirect(appConfigService.config.providers)).toBeNull(); }); + + it('[ECM] should return isECMProvider true', () => { + expect(authService.isECMProvider()).toBe(true); + }); + + it('[ECM] should return isBPMProvider false', () => { + expect(authService.isBPMProvider()).toBe(false); + }); + + it('[ECM] should return isALLProvider false', () => { + expect(authService.isALLProvider()).toBe(false); + }); + + it('[ECM] should return isBpmLoggedIn false', () => { + expect(authService.isBpmLoggedIn()).toBe(false); + }); }); describe('when the setting is BPM', () => { @@ -233,6 +251,7 @@ describe('AuthenticationService', () => { it('should require remember me set for BPM check', () => { spyOn(cookie, 'isEnabled').and.returnValue(true); spyOn(authService, 'isRememberMeSet').and.returnValue(false); + spyOn(authService, 'isBPMProvider').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(false); spyOn(apiService, 'getInstance').and.callThrough(); @@ -243,6 +262,7 @@ describe('AuthenticationService', () => { it('should not require cookie service enabled for BPM check', () => { spyOn(cookie, 'isEnabled').and.returnValue(false); spyOn(authService, 'isRememberMeSet').and.returnValue(false); + spyOn(authService, 'isBPMProvider').and.returnValue(true); spyOn(apiService, 'getInstance').and.callThrough(); expect(authService.isBpmLoggedIn()).toBeFalsy(); @@ -317,6 +337,18 @@ describe('AuthenticationService', () => { expect(authService.getRedirect(appConfigService.config.providers)).toBeNull(); }); + + it('[BPM] should return isECMProvider false', () => { + expect(authService.isECMProvider()).toBe(false); + }); + + it('[BPM] should return isBPMProvider true', () => { + expect(authService.isBPMProvider()).toBe(true); + }); + + it('[BPM] should return isALLProvider false', () => { + expect(authService.isALLProvider()).toBe(false); + }); }); describe('when the setting is both ECM and BPM ', () => { @@ -441,6 +473,18 @@ describe('AuthenticationService', () => { expect(authService.getRedirect(appConfigService.config.providers)).toBeNull(); }); + + it('[ALL] should return isECMProvider false', () => { + expect(authService.isECMProvider()).toBe(false); + }); + + it('[ALL] should return isBPMProvider false', () => { + expect(authService.isBPMProvider()).toBe(false); + }); + + it('[ALL] should return isALLProvider true', () => { + expect(authService.isALLProvider()).toBe(true); + }); }); }); diff --git a/lib/core/services/authentication.service.ts b/lib/core/services/authentication.service.ts index 8304a5f44c..b7a8521a06 100644 --- a/lib/core/services/authentication.service.ts +++ b/lib/core/services/authentication.service.ts @@ -56,6 +56,18 @@ export class AuthenticationService { return this.alfrescoApi.getInstance().isOauthConfiguration(); } + isECMProvider(): boolean { + return this.alfrescoApi.getInstance().isEcmConfiguration(); + } + + isBPMProvider(): boolean { + return this.alfrescoApi.getInstance().isBpmConfiguration(); + } + + isALLProvider(): boolean { + return this.alfrescoApi.getInstance().isEcmBpmConfiguration(); + } + /** * Logs the user in. * @param username Username for the login @@ -162,10 +174,13 @@ export class AuthenticationService { * @returns True if logged in, false otherwise */ isEcmLoggedIn(): boolean { - if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) { - return false; + if (this.isECMProvider() || this.isALLProvider()) { + if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) { + return false; + } + return this.alfrescoApi.getInstance().isEcmLoggedIn(); } - return this.alfrescoApi.getInstance().isEcmLoggedIn(); + return false; } /** @@ -173,10 +188,13 @@ export class AuthenticationService { * @returns True if logged in, false otherwise */ isBpmLoggedIn(): boolean { - if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) { - return false; + if (this.isBPMProvider() || this.isALLProvider()) { + if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) { + return false; + } + return this.alfrescoApi.getInstance().isBpmLoggedIn(); } - return this.alfrescoApi.getInstance().isBpmLoggedIn(); + return false; } /**