mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Ability to check if loggedIn based on provider (#5598)
* Provide a way to check if loggedIn based on provider * Fix the comments * Add schema validation for provider
This commit is contained in:
@@ -76,6 +76,11 @@ describe('AuthenticationService', () => {
|
||||
expect(apiService.getInstance).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should check if loggedin on ECM in case the provider is ECM', () => {
|
||||
spyOn(authService, 'isEcmLoggedIn').and.returnValue(true);
|
||||
expect(authService.isLoggedInWith('ECM')).toBe(true);
|
||||
});
|
||||
|
||||
it('should require remember me set for ECM check', () => {
|
||||
spyOn(cookie, 'isEnabled').and.returnValue(true);
|
||||
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
|
||||
@@ -198,6 +203,11 @@ describe('AuthenticationService', () => {
|
||||
expect(apiService.getInstance).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should check if loggedin on BPM in case the provider is BPM', () => {
|
||||
spyOn(authService, 'isBpmLoggedIn').and.returnValue(true);
|
||||
expect(authService.isLoggedInWith('BPM')).toBe(true);
|
||||
});
|
||||
|
||||
it('should not require cookie service enabled for BPM check', () => {
|
||||
spyOn(cookie, 'isEnabled').and.returnValue(false);
|
||||
spyOn(authService, 'isRememberMeSet').and.returnValue(false);
|
||||
|
@@ -61,6 +61,16 @@ export class AuthenticationService {
|
||||
return this.alfrescoApi.getInstance().isLoggedIn();
|
||||
}
|
||||
|
||||
isLoggedInWith(provider: string): boolean {
|
||||
if (provider === 'BPM') {
|
||||
return this.isBpmLoggedIn();
|
||||
} else if (provider === 'ECM') {
|
||||
return this.isEcmLoggedIn();
|
||||
} else {
|
||||
return this.isLoggedIn();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the provider support OAuth?
|
||||
* @returns True if supported, false otherwise
|
||||
|
Reference in New Issue
Block a user