mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +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();
|
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', () => {
|
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);
|
||||||
@@ -198,6 +203,11 @@ describe('AuthenticationService', () => {
|
|||||||
expect(apiService.getInstance).not.toHaveBeenCalled();
|
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', () => {
|
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);
|
||||||
|
@@ -61,6 +61,16 @@ export class AuthenticationService {
|
|||||||
return this.alfrescoApi.getInstance().isLoggedIn();
|
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?
|
* Does the provider support OAuth?
|
||||||
* @returns True if supported, false otherwise
|
* @returns True if supported, false otherwise
|
||||||
|
@@ -25,6 +25,7 @@ export interface NavBarLinkRef extends ExtensionElement {
|
|||||||
icon: string;
|
icon: string;
|
||||||
title: string;
|
title: string;
|
||||||
route: string;
|
route: string;
|
||||||
|
provider?: string;
|
||||||
|
|
||||||
url?: string; // evaluated at runtime based on route ref
|
url?: string; // evaluated at runtime based on route ref
|
||||||
description?: string;
|
description?: string;
|
||||||
|
@@ -178,6 +178,11 @@
|
|||||||
"description": "Unique identifier",
|
"description": "Unique identifier",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"provider": {
|
||||||
|
"description": "Define on which system the user should be authenticate",
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["BPM", "ECM", "ALL"]
|
||||||
|
},
|
||||||
"icon": {
|
"icon": {
|
||||||
"description": "Element icon",
|
"description": "Element icon",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
Reference in New Issue
Block a user