Skip to content

Commit e0a9ffd

Browse files
authored
Merge pull request #427 from intersystems-community/api-cookies
attempt to solve issue with cookies
2 parents 1d18c1c + d11b304 commit e0a9ffd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/api/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { currentWorkspaceFolder, outputConsole, outputChannel } from "../utils";
1818
const DEFAULT_API_VERSION = 1;
1919
import * as Atelier from "./atelier";
2020

21+
let authRequest = null;
22+
2123
export interface ConnectionSettings {
2224
serverName: string;
2325
active: boolean;
@@ -119,7 +121,8 @@ export class AtelierAPI {
119121
}
120122

121123
public get cookies(): string[] {
122-
return this.cache.get("cookies", []);
124+
const cookies = this.cache.get("cookies", []);
125+
return cookies;
123126
}
124127

125128
public clearCookies(): void {
@@ -262,7 +265,10 @@ export class AtelierAPI {
262265
auth = Promise.resolve(cookies);
263266
headers["Authorization"] = `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`;
264267
} else if (!cookies.length) {
265-
auth = this.request(0, "HEAD");
268+
if (!authRequest) {
269+
authRequest = this.request(0, "HEAD");
270+
}
271+
auth = authRequest;
266272
}
267273
const connInfo = `${host}:${port}[${this.ns}]`;
268274

@@ -292,6 +298,7 @@ export class AtelierAPI {
292298
panel.text = `${connInfo}`;
293299
panel.tooltip = `Connected as ${username}`;
294300
if (method === "HEAD") {
301+
authRequest = null;
295302
return this.cookies;
296303
}
297304

0 commit comments

Comments
 (0)