Skip to content

Commit cfc6a12

Browse files
author
Rachel Macfarlane
committed
Add logout method to auth provider API
1 parent 4e5840c commit cfc6a12

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/vs/vscode.proposed.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ declare module 'vscode' {
128128
*/
129129
export function login(providerId: string, scopes: string[]): Thenable<AuthenticationSession>;
130130

131+
/**
132+
* Logout of a specific session.
133+
* @param providerId The id of the provider to use
134+
* @param sessionId The session id to remove
135+
* provider
136+
*/
137+
export function logout(providerId: string, sessionId: string): Thenable<void>;
138+
131139
/**
132140
* An [event](#Event) which fires when the array of sessions has changed, or data
133141
* within a session has changed for a provider. Fires with the ids of the providers

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
202202
login(providerId: string, scopes: string[]): Thenable<vscode.AuthenticationSession> {
203203
return extHostAuthentication.login(extension, providerId, scopes);
204204
},
205+
logout(providerId: string, sessionId: string): Thenable<void> {
206+
return extHostAuthentication.logout(providerId, sessionId);
207+
},
205208
get onDidChangeSessions(): Event<{ [providerId: string]: vscode.AuthenticationSessionsChangeEvent }> {
206209
return extHostAuthentication.onDidChangeSessions;
207210
},

src/vs/workbench/api/common/extHostAuthentication.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
102102
};
103103
}
104104

105+
async logout(providerId: string, sessionId: string): Promise<void> {
106+
const provider = this._authenticationProviders.get(providerId);
107+
if (!provider) {
108+
throw new Error(`No authentication provider with id '${providerId}' is currently registered.`);
109+
}
110+
111+
return provider.logout(sessionId);
112+
}
113+
105114
registerAuthenticationProvider(provider: vscode.AuthenticationProvider): vscode.Disposable {
106115
if (this._authenticationProviders.get(provider.id)) {
107116
throw new Error(`An authentication provider with id '${provider.id}' is already registered.`);

0 commit comments

Comments
 (0)