Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AAE-18459] Fix invalidateSession is called when auth is not initilized by js-api #9152

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/core/src/lib/app-config/app-config.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,20 @@ describe('AppConfigService', () => {
expect(fakeCallBack).toHaveBeenCalled();
});

it('should replace all the configuration placeholders if the provided key is an object', () => {
appConfigService.config.objectKey = {
firstUrl: '{protocol}//{hostname}{:port}',
secondUrl: '{protocol}//{hostname}{:port}',
thirdUrl: '{protocol}//{hostname}{:port}'
};
spyOn(appConfigService, 'getLocationHostname').and.returnValue('localhost');
spyOn(appConfigService, 'getLocationPort').and.returnValue(':8080');
spyOn(appConfigService, 'getLocationProtocol').and.returnValue('http:');

expect(appConfigService.get<any>('objectKey').firstUrl).toEqual('http://localhost:8080');
expect(appConfigService.get<any>('objectKey').secondUrl).toEqual('http://localhost:8080');
expect(appConfigService.get<any>('objectKey').thirdUrl).toEqual('http://localhost:8080');
});


});
6 changes: 3 additions & 3 deletions lib/core/src/lib/app-config/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ export class AppConfigService {
}

if (typeof result === 'object') {
result = JSON.parse(JSON.stringify(result).replace('{hostname}', this.getLocationHostname()));
result = JSON.parse(JSON.stringify(result).replace('{:port}', this.getLocationPort(':')));
result = JSON.parse(JSON.stringify(result).replace('{protocol}', this.getLocationProtocol()));
result = JSON.parse(JSON.stringify(result).replace(/{hostname}/g, this.getLocationHostname()));
result = JSON.parse(JSON.stringify(result).replace(/{:port}/g, this.getLocationPort(':')));
result = JSON.parse(JSON.stringify(result).replace(/{protocol}/g, this.getLocationProtocol()));
}

if (result === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion lib/js-api/src/alfrescoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class AlfrescoApi implements Emitter, AlfrescoApiType {

/**@private? */
errorHandler(error: { status?: number }) {
if (error.status === 401) {
if (this.config.oauthInit && error.status === 401) {
this.invalidateSession();
}

Expand Down
Loading