1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-07 12:30:06 +00:00

feat: csrf token main file sync

This commit is contained in:
Mihajlo Medjedovic
2020-07-20 20:34:12 +02:00
parent 8bf74d17e9
commit ee024c67ab
3 changed files with 34 additions and 17 deletions

View File

@@ -20,6 +20,7 @@ export class SASViyaApiClient {
private serverUrl: string,
private rootFolderName: string,
private contextName: string,
private setCsrfToken: (csrfToken: CsrfToken) => void,
private rootFolderMap = new Map<string, Job[]>()
) {
if (!rootFolderName) {
@@ -28,7 +29,7 @@ export class SASViyaApiClient {
}
private csrfToken: CsrfToken | null = null;
private rootFolder: Folder | null = null;
private sessionManager = new SessionManager(this.serverUrl, this.contextName);
private sessionManager = new SessionManager(this.serverUrl, this.contextName, this.setCsrfToken);
/**
* Returns a map containing the directory structure in the currently set root folder.
@@ -1025,8 +1026,9 @@ export class SASViyaApiClient {
return `/folders/folders/${folder.id}`;
}
setCsrfToken = (csrfToken: CsrfToken) => {
setCsrfTokenLocal = (csrfToken: CsrfToken) => {
this.csrfToken = csrfToken;
this.setCsrfToken(csrfToken);
};
private async request<T>(
@@ -1040,6 +1042,6 @@ export class SASViyaApiClient {
[this.csrfToken.headerName]: this.csrfToken.value,
};
}
return await makeRequest<T>(url, options, this.setCsrfToken, contentType);
return await makeRequest<T>(url, options, this.setCsrfTokenLocal, contentType);
}
}