From fd2ced449b8840c6054192e4e9c795d8730340c7 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com> Date: Mon, 9 Jan 2023 21:22:02 -0800 Subject: [PATCH] Skip fetching access token when opening context menu in OE (#21557) --- src/sql/platform/connection/common/connectionManagement.ts | 2 +- .../connection/browser/connectionManagementService.ts | 6 ++++-- .../objectExplorer/browser/serverTreeActionProvider.ts | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sql/platform/connection/common/connectionManagement.ts b/src/sql/platform/connection/common/connectionManagement.ts index 3711bd80eb..fb4a80f6a5 100644 --- a/src/sql/platform/connection/common/connectionManagement.ts +++ b/src/sql/platform/connection/common/connectionManagement.ts @@ -202,7 +202,7 @@ export interface IConnectionManagementService { disconnect(ownerUri: string): Promise; - addSavedPassword(connectionProfile: IConnectionProfile): Promise; + addSavedPassword(connectionProfile: IConnectionProfile, skipAccessToken?: boolean): Promise; listDatabases(connectionUri: string): Thenable; diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index 4fdcffa5d2..4594e0b918 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -255,8 +255,10 @@ export class ConnectionManagementService extends Disposable implements IConnecti * Load the password for the profile * @param connectionProfile Connection Profile */ - public async addSavedPassword(connectionProfile: interfaces.IConnectionProfile): Promise { - await this.fillInOrClearToken(connectionProfile); + public async addSavedPassword(connectionProfile: interfaces.IConnectionProfile, skipAccessToken: boolean = false): Promise { + if (!skipAccessToken) { + await this.fillInOrClearToken(connectionProfile); + } return this._connectionStore.addSavedPassword(connectionProfile).then(result => result.profile); } diff --git a/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts b/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts index 224af85463..73bf12b48b 100644 --- a/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts +++ b/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts @@ -70,7 +70,8 @@ export class ServerTreeActionProvider { */ private getConnectionActions(tree: AsyncServerTree | ITree, profile: ConnectionProfile): IAction[] { let node = new TreeNode(NodeType.Server, NodeType.Server, '', false, '', '', '', undefined, undefined, undefined, undefined); - this._connectionManagementService.addSavedPassword(profile); + // Only update password and not access tokens to avoid login prompts when opening context menu. + this._connectionManagementService.addSavedPassword(profile, true); node.connection = profile; return this.getAllActions({ tree: tree,