1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-11 14:20:05 +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

@@ -4,7 +4,11 @@ import { asyncForEach, makeRequest } from "./utils";
const MAX_SESSION_COUNT = 1;
export class SessionManager {
constructor(private serverUrl: string, private contextName: string) {}
constructor(
private serverUrl: string,
private contextName: string,
private setCsrfToken: (csrfToken: CsrfToken) => void
) {}
private sessions: Session[] = [];
private currentContext: Context | null = null;
private csrfToken: CsrfToken | null = null;
@@ -132,7 +136,10 @@ export class SessionManager {
return await makeRequest<T>(
url,
options,
(token) => (this.csrfToken = token),
(token) => {
this.csrfToken = token;
this.setCsrfToken(token);
},
contentType
);
}