Skip to content

Try to end /api/atelier web sessions when extension deactivates #267

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
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/authenticationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { ServerManagerAuthenticationSession } from "./authenticationSession";
import { globalState } from "./commonActivate";
import { getServerSpec } from "./api/getServerSpec";
import { makeRESTRequest } from "./makeRESTRequest";
import { logout, makeRESTRequest } from "./makeRESTRequest";

export const AUTHENTICATION_PROVIDER = "intersystems-server-credentials";
const AUTHENTICATION_PROVIDER_LABEL = "InterSystems Server Credentials";
Expand Down Expand Up @@ -230,6 +230,8 @@ export class ServerManagerAuthenticationProvider implements AuthenticationProvid
await this._removeSession(session.id, true);
return false;
}
// Immediately log out the session created by credentials test
await logout(session.serverName);
}
this._checkedSessions.push(session);
return true;
Expand Down
11 changes: 10 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as vscode from "vscode";
import { importFromRegistry } from "./commands/importFromRegistry";
import { ServerManagerView } from "./ui/serverManagerView";
import { commonActivate, extensionId } from "./commonActivate";
import { logout, serverSessions } from "./makeRESTRequest";

export function activate(context: vscode.ExtensionContext) {
const view = new ServerManagerView(context);
Expand All @@ -20,4 +21,12 @@ export function activate(context: vscode.ExtensionContext) {
return commonActivate(context, view);
}

export function deactivate() { }
export async function deactivate() {
// Do our best to log out of all sessions

const promises: Promise<any>[] = [];
for (const serverSession of serverSessions) {
promises.push(logout(serverSession[1].serverName));
}
await Promise.allSettled(promises);
}
17 changes: 13 additions & 4 deletions src/web-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
import * as vscode from "vscode";
import { ServerManagerView } from "./ui/serverManagerView";
import { commonActivate } from "./commonActivate";
import { logout, serverSessions } from "./makeRESTRequest";

export function activate(context: vscode.ExtensionContext) {
const view = new ServerManagerView(context);
const view = new ServerManagerView(context);

// Common activation steps
return commonActivate(context, view);
// Common activation steps
return commonActivate(context, view);
}

export function deactivate() { }
export async function deactivate() {
// Do our best to log out of all sessions

const promises: Promise<any>[] = [];
for (const serverSession of serverSessions) {
promises.push(logout(serverSession[1].serverName));
}
await Promise.allSettled(promises);
}