From 3c8eb4c2cf85ee4476bb701a6dfd1a717ae7124c Mon Sep 17 00:00:00 2001 From: Amedeo Lepore Date: Mon, 11 Dec 2023 12:32:00 +0100 Subject: [PATCH 1/2] [AAE-18459] Replace all placeholders if the configuration key is an object --- .../lib/app-config/app-config.service.spec.ts | 16 ++++++++++++++++ .../src/lib/app-config/app-config.service.ts | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/core/src/lib/app-config/app-config.service.spec.ts b/lib/core/src/lib/app-config/app-config.service.spec.ts index a6b045da5fb..7ec1b98f959 100644 --- a/lib/core/src/lib/app-config/app-config.service.spec.ts +++ b/lib/core/src/lib/app-config/app-config.service.spec.ts @@ -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('objectKey').firstUrl).toEqual('http://localhost:8080'); + expect(appConfigService.get('objectKey').secondUrl).toEqual('http://localhost:8080'); + expect(appConfigService.get('objectKey').thirdUrl).toEqual('http://localhost:8080'); + }); + + }); diff --git a/lib/core/src/lib/app-config/app-config.service.ts b/lib/core/src/lib/app-config/app-config.service.ts index 314522a5add..c0e0606f6bc 100644 --- a/lib/core/src/lib/app-config/app-config.service.ts +++ b/lib/core/src/lib/app-config/app-config.service.ts @@ -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) { From 60bd291b8c0c10b79c807b28534bb8bbf0ca9293 Mon Sep 17 00:00:00 2001 From: Amedeo Lepore Date: Mon, 11 Dec 2023 15:31:31 +0100 Subject: [PATCH 2/2] [AAE-18459] don't invalidate session if authentication is not handled by js-api --- lib/js-api/src/alfrescoApi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/js-api/src/alfrescoApi.ts b/lib/js-api/src/alfrescoApi.ts index 33daa63b0f6..f46975c506b 100644 --- a/lib/js-api/src/alfrescoApi.ts +++ b/lib/js-api/src/alfrescoApi.ts @@ -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(); }