Skip to content

Commit 8cb98dd

Browse files
committed
feat: add zenstack logout command
1 parent 188ff5f commit 8cb98dd

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

packages/schema/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
},
8888
{
8989
"command": "zenstack.clear-documentation-cache"
90+
},
91+
{
92+
"command": "zenstack.logout"
9093
}
9194
]
9295
},
@@ -100,6 +103,11 @@
100103
"command": "zenstack.clear-documentation-cache",
101104
"title": "ZenStack: Clear Documentation Cache",
102105
"icon": "$(trash)"
106+
},
107+
{
108+
"command": "zenstack.logout",
109+
"title": "ZenStack: Logout",
110+
"icon": "$(log-out)"
103111
}
104112
],
105113
"keybindings": [

packages/schema/src/zenstack-auth-provider.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export class ZenStackAuthenticationProvider implements vscode.AuthenticationProv
3737
await this.handleAuthCallback(uri);
3838
}
3939
},
40+
}),
41+
// Register logout command
42+
vscode.commands.registerCommand('zenstack.logout', async () => {
43+
await this.logoutAllSessions();
4044
})
4145
);
4246
}
@@ -77,6 +81,18 @@ export class ZenStackAuthenticationProvider implements vscode.AuthenticationProv
7781
}
7882
}
7983

84+
/**
85+
* Log out all sessions
86+
*/
87+
async logoutAllSessions(): Promise<void> {
88+
if (this._sessions.length === 0) {
89+
return;
90+
}
91+
92+
(await this.getSessions()).forEach(async (s) => await this.removeSession(s.id));
93+
vscode.window.showInformationMessage('Successfully logged out of ZenStack.');
94+
}
95+
8096
private async performLogin(scopes: readonly string[]): Promise<vscode.AuthenticationSession> {
8197
// Create the authentication promise
8298
return vscode.window.withProgress(

0 commit comments

Comments
 (0)