From f2afe1cf8a91f8335e938eda853009dd869a1d62 Mon Sep 17 00:00:00 2001 From: Amedeo Lepore Date: Wed, 5 Apr 2023 12:47:59 +0200 Subject: [PATCH] [AAE-12501] Get disableCsrf from app config serviice when app configuration is loaded --- .../api/src/lib/adf-http-client.service.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/core/api/src/lib/adf-http-client.service.ts b/lib/core/api/src/lib/adf-http-client.service.ts index b4315d2d0c..6f35384ff3 100644 --- a/lib/core/api/src/lib/adf-http-client.service.ts +++ b/lib/core/api/src/lib/adf-http-client.service.ts @@ -274,26 +274,26 @@ export class AdfHttpClient implements ee.Emitter,JsApiHttpClient { if (!this.disableCsrf) { this.setCsrfToken(optionsHeaders); - // } + } return new HttpHeaders(optionsHeaders); } - // private setCsrfToken(optionsHeaders: any) { - // const token = this.createCSRFToken(); - // optionsHeaders['X-CSRF-TOKEN'] = token; + private setCsrfToken(optionsHeaders: any) { + const token = this.createCSRFToken(); + optionsHeaders['X-CSRF-TOKEN'] = token; - // try { - // document.cookie = 'CSRF-TOKEN=' + token + ';path=/'; - // } catch (err) { - // /* continue regardless of error */ - // } - // } + try { + document.cookie = 'CSRF-TOKEN=' + token + ';path=/'; + } catch (err) { + /* continue regardless of error */ + } + } - // private createCSRFToken(a?: any): string { - // const randomValue = window.crypto.getRandomValues(new Uint32Array(1))[0]; - // return a ? (a ^ ((randomValue * 16) >> (a / 4))).toString(16) : ([1e16] + (1e16).toString()).replace(/[01]/g, this.createCSRFToken); - // } + private createCSRFToken(a?: any): string { + const randomValue = window.crypto.getRandomValues(new Uint32Array(1))[0]; + return a ? (a ^ ((randomValue * 16) >> (a / 4))).toString(16) : ([1e16] + (1e16).toString()).replace(/[01]/g, this.createCSRFToken); + } private static getResponseType(options: RequestOptions): 'blob' | 'json' | 'text' {