mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[AAE-12501] Comment temporary setCsrfToken because is not possible to import app config service from core due to circular dependencies
This commit is contained in:
@@ -42,7 +42,7 @@ import { AlfrescoApiParamEncoder } from './alfresco-api/alfresco-api.param-encod
|
||||
import { AlfrescoApiResponseError } from './alfresco-api/alfresco-api.response-error';
|
||||
import { Constructor } from './types';
|
||||
import { RequestOptions, SecurityOptions } from './interfaces';
|
||||
import { AppConfigService, AppConfigValues } from '../../../src/lib/app-config/app-config.service';
|
||||
// import { AppConfigService, AppConfigValues } from '../../../src/lib/app-config/app-config.service';
|
||||
import ee, { Emitter } from 'event-emitter';
|
||||
|
||||
export interface Emitters {
|
||||
@@ -67,7 +67,9 @@ export class AdfHttpClient implements ee.Emitter,JsApiHttpClient {
|
||||
defaultHeaders: {}
|
||||
};
|
||||
|
||||
constructor(private httpClient: HttpClient, private appConfig: AppConfigService) {
|
||||
constructor(private httpClient: HttpClient
|
||||
// private appConfig: AppConfigService
|
||||
) {
|
||||
ee(this);
|
||||
}
|
||||
|
||||
@@ -262,31 +264,31 @@ export class AdfHttpClient implements ee.Emitter,JsApiHttpClient {
|
||||
...((options.contentType) && {'Content-Type': options.contentType})
|
||||
};
|
||||
|
||||
const disableCsrf = this.appConfig.get<boolean>(AppConfigValues.DISABLECSRF);
|
||||
// const disableCsrf = this.appConfig.get<boolean>(AppConfigValues.DISABLECSRF);
|
||||
|
||||
if (!disableCsrf) {
|
||||
this.setCsrfToken(optionsHeaders);
|
||||
// if (!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' {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user