mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3251] Authentication Service - Check if used loggedin based on the provider (#3515)
* check if loggedin based on the provider * Fix unit tests
This commit is contained in:
committed by
Eugenio Romano
parent
3e0e2609f7
commit
9b2d51dbd5
@@ -129,6 +129,7 @@ describe('AuthenticationService', () => {
|
|||||||
it('should require remember me set for ECM check', () => {
|
it('should require remember me set for ECM check', () => {
|
||||||
spyOn(cookie, 'isEnabled').and.returnValue(true);
|
spyOn(cookie, 'isEnabled').and.returnValue(true);
|
||||||
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
|
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
|
||||||
|
spyOn(authService, 'isECMProvider').and.returnValue(true);
|
||||||
spyOn(authService, 'isOauth').and.returnValue(false);
|
spyOn(authService, 'isOauth').and.returnValue(false);
|
||||||
spyOn(apiService, 'getInstance').and.callThrough();
|
spyOn(apiService, 'getInstance').and.callThrough();
|
||||||
|
|
||||||
@@ -139,6 +140,7 @@ describe('AuthenticationService', () => {
|
|||||||
it('should not require cookie service enabled for ECM check', () => {
|
it('should not require cookie service enabled for ECM check', () => {
|
||||||
spyOn(cookie, 'isEnabled').and.returnValue(false);
|
spyOn(cookie, 'isEnabled').and.returnValue(false);
|
||||||
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
|
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
|
||||||
|
spyOn(authService, 'isECMProvider').and.returnValue(true);
|
||||||
spyOn(authService, 'isOauth').and.returnValue(false);
|
spyOn(authService, 'isOauth').and.returnValue(false);
|
||||||
spyOn(apiService, 'getInstance').and.callThrough();
|
spyOn(apiService, 'getInstance').and.callThrough();
|
||||||
|
|
||||||
@@ -220,6 +222,22 @@ describe('AuthenticationService', () => {
|
|||||||
|
|
||||||
expect(authService.getRedirect(appConfigService.config.providers)).toBeNull();
|
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', () => {
|
describe('when the setting is BPM', () => {
|
||||||
@@ -233,6 +251,7 @@ describe('AuthenticationService', () => {
|
|||||||
it('should require remember me set for BPM check', () => {
|
it('should require remember me set for BPM check', () => {
|
||||||
spyOn(cookie, 'isEnabled').and.returnValue(true);
|
spyOn(cookie, 'isEnabled').and.returnValue(true);
|
||||||
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
|
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
|
||||||
|
spyOn(authService, 'isBPMProvider').and.returnValue(true);
|
||||||
spyOn(authService, 'isOauth').and.returnValue(false);
|
spyOn(authService, 'isOauth').and.returnValue(false);
|
||||||
spyOn(apiService, 'getInstance').and.callThrough();
|
spyOn(apiService, 'getInstance').and.callThrough();
|
||||||
|
|
||||||
@@ -243,6 +262,7 @@ describe('AuthenticationService', () => {
|
|||||||
it('should not require cookie service enabled for BPM check', () => {
|
it('should not require cookie service enabled for BPM check', () => {
|
||||||
spyOn(cookie, 'isEnabled').and.returnValue(false);
|
spyOn(cookie, 'isEnabled').and.returnValue(false);
|
||||||
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
|
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
|
||||||
|
spyOn(authService, 'isBPMProvider').and.returnValue(true);
|
||||||
spyOn(apiService, 'getInstance').and.callThrough();
|
spyOn(apiService, 'getInstance').and.callThrough();
|
||||||
|
|
||||||
expect(authService.isBpmLoggedIn()).toBeFalsy();
|
expect(authService.isBpmLoggedIn()).toBeFalsy();
|
||||||
@@ -317,6 +337,18 @@ describe('AuthenticationService', () => {
|
|||||||
|
|
||||||
expect(authService.getRedirect(appConfigService.config.providers)).toBeNull();
|
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 ', () => {
|
describe('when the setting is both ECM and BPM ', () => {
|
||||||
@@ -441,6 +473,18 @@ describe('AuthenticationService', () => {
|
|||||||
|
|
||||||
expect(authService.getRedirect(appConfigService.config.providers)).toBeNull();
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -56,6 +56,18 @@ export class AuthenticationService {
|
|||||||
return this.alfrescoApi.getInstance().isOauthConfiguration();
|
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.
|
* Logs the user in.
|
||||||
* @param username Username for the login
|
* @param username Username for the login
|
||||||
@@ -162,22 +174,28 @@ export class AuthenticationService {
|
|||||||
* @returns True if logged in, false otherwise
|
* @returns True if logged in, false otherwise
|
||||||
*/
|
*/
|
||||||
isEcmLoggedIn(): boolean {
|
isEcmLoggedIn(): boolean {
|
||||||
|
if (this.isECMProvider() || this.isALLProvider()) {
|
||||||
if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) {
|
if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.alfrescoApi.getInstance().isEcmLoggedIn();
|
return this.alfrescoApi.getInstance().isEcmLoggedIn();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the user is logged in on a BPM provider.
|
* Checks if the user is logged in on a BPM provider.
|
||||||
* @returns True if logged in, false otherwise
|
* @returns True if logged in, false otherwise
|
||||||
*/
|
*/
|
||||||
isBpmLoggedIn(): boolean {
|
isBpmLoggedIn(): boolean {
|
||||||
|
if (this.isBPMProvider() || this.isALLProvider()) {
|
||||||
if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) {
|
if (!this.isOauth() && this.cookie.isEnabled() && !this.isRememberMeSet()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.alfrescoApi.getInstance().isBpmLoggedIn();
|
return this.alfrescoApi.getInstance().isBpmLoggedIn();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ECM username.
|
* Gets the ECM username.
|
||||||
|
Reference in New Issue
Block a user