Skip to content

Log out of web sessions when VS Code exits #1540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,7 @@ async function asyncServerForUri(uri: vscode.Uri): Promise<any> {
return server;
}

export function deactivate(): void {
export async function deactivate(): Promise<void> {
if (workspaceState) {
workspaceState.update("openedClasses", openedClasses);
}
Expand All @@ -1770,4 +1770,25 @@ export function deactivate(): void {
incLangConf?.dispose();
intLangConf?.dispose();
disposeDocumentIndex();
// Log out of all CSP sessions
const loggedOut: Set<string> = new Set();
const promises: Promise<any>[] = [];
for (const f of vscode.workspace.workspaceFolders ?? []) {
const api = new AtelierAPI(f.uri);
if (!api.active || !api.cookies.length) continue;
const sessionCookie = api.cookies.find((c) => c.startsWith("CSPSESSIONID-"));
if (!sessionCookie || loggedOut.has(sessionCookie)) continue;
loggedOut.add(sessionCookie);
promises.push(
api.request(
0,
"HEAD",
undefined,
undefined,
// Prefer IRISLogout for servers that support it
semver.lt(api.config.serverVersion, "2018.2.0") ? { CacheLogout: "end" } : { IRISLogout: "end" }
)
);
}
await Promise.allSettled(promises);
}