Skip to content

Commit 9d292ea

Browse files
authored
Log out of web sessions when VS Code exits (#1540)
1 parent 8fd3ed1 commit 9d292ea

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/extension.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,7 @@ async function asyncServerForUri(uri: vscode.Uri): Promise<any> {
17831783
return server;
17841784
}
17851785

1786-
export function deactivate(): void {
1786+
export async function deactivate(): Promise<void> {
17871787
if (workspaceState) {
17881788
workspaceState.update("openedClasses", openedClasses);
17891789
}
@@ -1796,4 +1796,25 @@ export function deactivate(): void {
17961796
incLangConf?.dispose();
17971797
intLangConf?.dispose();
17981798
disposeDocumentIndex();
1799+
// Log out of all CSP sessions
1800+
const loggedOut: Set<string> = new Set();
1801+
const promises: Promise<any>[] = [];
1802+
for (const f of vscode.workspace.workspaceFolders ?? []) {
1803+
const api = new AtelierAPI(f.uri);
1804+
if (!api.active || !api.cookies.length) continue;
1805+
const sessionCookie = api.cookies.find((c) => c.startsWith("CSPSESSIONID-"));
1806+
if (!sessionCookie || loggedOut.has(sessionCookie)) continue;
1807+
loggedOut.add(sessionCookie);
1808+
promises.push(
1809+
api.request(
1810+
0,
1811+
"HEAD",
1812+
undefined,
1813+
undefined,
1814+
// Prefer IRISLogout for servers that support it
1815+
semver.lt(api.config.serverVersion, "2018.2.0") ? { CacheLogout: "end" } : { IRISLogout: "end" }
1816+
)
1817+
);
1818+
}
1819+
await Promise.allSettled(promises);
17991820
}

0 commit comments

Comments
 (0)