mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[AAE-9094] - Fix app breaking when configured with BASIC auth (#7672)
This commit is contained in:
parent
1b20e17ed7
commit
81e58ecfb2
@ -92,6 +92,7 @@ describe('UserAccessService', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(jwtHelperService, 'getValueFromLocalToken').and.returnValue(undefined);
|
spyOn(jwtHelperService, 'getValueFromLocalToken').and.returnValue(undefined);
|
||||||
getAccessFromApiSpy = spyOn(oauth2Service, 'get').and.returnValue(of(userAccessMock));
|
getAccessFromApiSpy = spyOn(oauth2Service, 'get').and.returnValue(of(userAccessMock));
|
||||||
|
appConfigService.config.authType = 'OAUTH';
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true when the user has one of the global roles', async () => {
|
it('should return true when the user has one of the global roles', async () => {
|
||||||
@ -137,5 +138,12 @@ describe('UserAccessService', () => {
|
|||||||
|
|
||||||
expect(getAccessFromApiSpy).toHaveBeenCalledWith({ url: `${ fakeIdentityHost }/v1/identity/roles` });
|
expect(getAccessFromApiSpy).toHaveBeenCalledWith({ url: `${ fakeIdentityHost }/v1/identity/roles` });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not fetch the access from the API if is not configured with OAUTH', async () => {
|
||||||
|
appConfigService.config.authType = 'BASIC';
|
||||||
|
await userAccessService.fetchUserAccess();
|
||||||
|
|
||||||
|
expect(getAccessFromApiSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -36,7 +36,11 @@ export class UserAccessService {
|
|||||||
|
|
||||||
async fetchUserAccess() {
|
async fetchUserAccess() {
|
||||||
if (!this.hasFetchedAccess()) {
|
if (!this.hasFetchedAccess()) {
|
||||||
this.hasRolesInJwt() ? this.fetchAccessFromJwt() : await this.fetchAccessFromApi();
|
if (this.hasRolesInJwt()) {
|
||||||
|
this.fetchAccessFromJwt();
|
||||||
|
} else if (this.isOauth()) {
|
||||||
|
await this.fetchAccessFromApi();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +71,10 @@ export class UserAccessService {
|
|||||||
return `${this.appConfigService.get('identityHost')}`;
|
return `${this.appConfigService.get('identityHost')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isOauth(): boolean {
|
||||||
|
return this.appConfigService.get('authType') === 'OAUTH';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for global roles access.
|
* Checks for global roles access.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user