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:
Maurizio Vitale
2020-04-08 16:43:36 +01:00
committed by GitHub
parent e55d3e53bb
commit 83e362d31a
4 changed files with 26 additions and 0 deletions

View File

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

View File

@@ -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

View File

@@ -25,6 +25,7 @@ export interface NavBarLinkRef extends ExtensionElement {
icon: string;
title: string;
route: string;
provider?: string;
url?: string; // evaluated at runtime based on route ref
description?: string;

View File

@@ -178,6 +178,11 @@
"description": "Unique identifier",
"type": "string"
},
"provider": {
"description": "Define on which system the user should be authenticate",
"type": "string",
"enum": ["BPM", "ECM", "ALL"]
},
"icon": {
"description": "Element icon",
"type": "string"