Skip to content

Commit 357fe69

Browse files
author
Rachel Macfarlane
committed
Ensure account preference set after login flow completes
1 parent cd5b4a7 commit 357fe69

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/vs/workbench/api/browser/mainThreadAuthentication.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
294294
}
295295

296296
const session = await this.authenticationService.login(providerId, scopes);
297-
await this.$setTrustedExtension(providerId, session.account.label, extensionId, extensionName);
297+
await this.$setTrustedExtensionAndAccountPreference(providerId, session.account.label, extensionId, extensionName, session.id);
298298
return session;
299299
} else {
300300
await this.$requestNewSession(providerId, scopes, extensionId, extensionName);
@@ -427,11 +427,13 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
427427
return choice === 0;
428428
}
429429

430-
async $setTrustedExtension(providerId: string, accountName: string, extensionId: string, extensionName: string): Promise<void> {
430+
async $setTrustedExtensionAndAccountPreference(providerId: string, accountName: string, extensionId: string, extensionName: string, sessionId: string): Promise<void> {
431431
const allowList = readAllowedExtensions(this.storageService, providerId, accountName);
432432
if (!allowList.find(allowed => allowed.id === extensionId)) {
433433
allowList.push({ id: extensionId, name: extensionName });
434434
this.storageService.store(`${providerId}-${accountName}`, JSON.stringify(allowList), StorageScope.GLOBAL);
435435
}
436+
437+
this.storageService.store(`${extensionName}-${providerId}`, sessionId, StorageScope.GLOBAL);
436438
}
437439
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export interface MainThreadAuthenticationShape extends IDisposable {
165165
$selectSession(providerId: string, providerName: string, extensionId: string, extensionName: string, potentialSessions: modes.AuthenticationSession[], scopes: string[], clearSessionPreference: boolean): Promise<modes.AuthenticationSession>;
166166
$getSessionsPrompt(providerId: string, accountName: string, providerName: string, extensionId: string, extensionName: string): Promise<boolean>;
167167
$loginPrompt(providerName: string, extensionName: string): Promise<boolean>;
168-
$setTrustedExtension(providerId: string, accountName: string, extensionId: string, extensionName: string): Promise<void>;
168+
$setTrustedExtensionAndAccountPreference(providerId: string, accountName: string, extensionId: string, extensionName: string, sessionId: string): Promise<void>;
169169
$requestNewSession(providerId: string, scopes: string[], extensionId: string, extensionName: string): Promise<void>;
170170

171171
$getSessions(providerId: string): Promise<ReadonlyArray<modes.AuthenticationSession>>;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
7575
}
7676

7777
const session = await provider.login(scopes);
78-
await this._proxy.$setTrustedExtension(providerId, session.account.label, extensionId, extensionName);
78+
await this._proxy.$setTrustedExtensionAndAccountPreference(providerId, session.account.label, extensionId, extensionName, session.id);
7979
return session;
8080
} else {
8181
await this._proxy.$requestNewSession(providerId, scopes, extensionId, extensionName);

0 commit comments

Comments
 (0)