Skip to content

Commit aa0d8bc

Browse files
Merge pull request #267 from gjsjohnmurray/violet-stork
Try to end /api/atelier web sessions when extension deactivates
2 parents ab32e85 + 8edd045 commit aa0d8bc

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/authenticationProvider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { ServerManagerAuthenticationSession } from "./authenticationSession";
1717
import { globalState } from "./commonActivate";
1818
import { getServerSpec } from "./api/getServerSpec";
19-
import { makeRESTRequest } from "./makeRESTRequest";
19+
import { logout, makeRESTRequest } from "./makeRESTRequest";
2020

2121
export const AUTHENTICATION_PROVIDER = "intersystems-server-credentials";
2222
const AUTHENTICATION_PROVIDER_LABEL = "InterSystems Server Credentials";
@@ -230,6 +230,8 @@ export class ServerManagerAuthenticationProvider implements AuthenticationProvid
230230
await this._removeSession(session.id, true);
231231
return false;
232232
}
233+
// Immediately log out the session created by credentials test
234+
await logout(session.serverName);
233235
}
234236
this._checkedSessions.push(session);
235237
return true;

src/extension.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as vscode from "vscode";
44
import { importFromRegistry } from "./commands/importFromRegistry";
55
import { ServerManagerView } from "./ui/serverManagerView";
66
import { commonActivate, extensionId } from "./commonActivate";
7+
import { logout, serverSessions } from "./makeRESTRequest";
78

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

23-
export function deactivate() { }
24+
export async function deactivate() {
25+
// Do our best to log out of all sessions
26+
27+
const promises: Promise<any>[] = [];
28+
for (const serverSession of serverSessions) {
29+
promises.push(logout(serverSession[1].serverName));
30+
}
31+
await Promise.allSettled(promises);
32+
}

src/web-extension.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@
33
import * as vscode from "vscode";
44
import { ServerManagerView } from "./ui/serverManagerView";
55
import { commonActivate } from "./commonActivate";
6+
import { logout, serverSessions } from "./makeRESTRequest";
67

78
export function activate(context: vscode.ExtensionContext) {
8-
const view = new ServerManagerView(context);
9+
const view = new ServerManagerView(context);
910

10-
// Common activation steps
11-
return commonActivate(context, view);
11+
// Common activation steps
12+
return commonActivate(context, view);
1213
}
1314

14-
export function deactivate() { }
15+
export async function deactivate() {
16+
// Do our best to log out of all sessions
17+
18+
const promises: Promise<any>[] = [];
19+
for (const serverSession of serverSessions) {
20+
promises.push(logout(serverSession[1].serverName));
21+
}
22+
await Promise.allSettled(promises);
23+
}

0 commit comments

Comments
 (0)