Skip to content

Commit f023ba2

Browse files
committed
Log out of web sessions when VS Code exits
1 parent e0ce455 commit f023ba2

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
@@ -1757,7 +1757,7 @@ async function asyncServerForUri(uri: vscode.Uri): Promise<any> {
17571757
return server;
17581758
}
17591759

1760-
export function deactivate(): void {
1760+
export async function deactivate(): Promise<void> {
17611761
if (workspaceState) {
17621762
workspaceState.update("openedClasses", openedClasses);
17631763
}
@@ -1770,4 +1770,25 @@ export function deactivate(): void {
17701770
incLangConf?.dispose();
17711771
intLangConf?.dispose();
17721772
disposeDocumentIndex();
1773+
// Log out of all CSP sessions
1774+
const loggedOut: Set<string> = new Set();
1775+
const promises: Promise<any>[] = [];
1776+
for (const f of vscode.workspace.workspaceFolders ?? []) {
1777+
const api = new AtelierAPI(f.uri);
1778+
if (!api.active || !api.cookies.length) continue;
1779+
const sessionCookie = api.cookies.find((c) => c.startsWith("CSPSESSIONID-"));
1780+
if (!sessionCookie || loggedOut.has(sessionCookie)) continue;
1781+
loggedOut.add(sessionCookie);
1782+
promises.push(
1783+
api.request(
1784+
0,
1785+
"HEAD",
1786+
undefined,
1787+
undefined,
1788+
// Prefer IRISLogout for servers that support it
1789+
semver.lt(api.config.serverVersion, "2018.2.0") ? { CacheLogout: "end" } : { IRISLogout: "end" }
1790+
)
1791+
);
1792+
}
1793+
await Promise.allSettled(promises);
17731794
}

0 commit comments

Comments
 (0)