From 2452651225268f330bd5776cb06ba7109782d931 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com> Date: Fri, 16 Feb 2024 23:02:28 +0530 Subject: [PATCH] Fix email comparisons to be case insensitive (#25330) --- .../accountManagement/browser/accountManagementService.ts | 2 +- .../services/connection/browser/connectionManagementService.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts b/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts index 7a2a33a0e00a..34825c24655c 100644 --- a/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts +++ b/src/sql/workbench/services/accountManagement/browser/accountManagementService.ts @@ -625,7 +625,7 @@ export class AccountManagementService implements IAccountManagementService { let indexToRemove: number = accounts.findIndex(account => { // corner case handling for personal accounts if (account.key.accountId.includes('#') || accountToFind.key.accountId.includes('#')) { - return account.displayInfo.email === accountToFind.displayInfo.email; + return account.displayInfo.email.toLocaleLowerCase() === accountToFind.displayInfo.email.toLocaleLowerCase(); } // MSAL account added if (accountToFind.key.accountId.includes('.')) { diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index cb5088b2c4d9..570ede190a50 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -1072,7 +1072,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti const azureAccounts = accounts.filter(a => a.key.providerId.startsWith('azure')); if (azureAccounts && azureAccounts.length > 0) { let accountId = (connection.authenticationType === Constants.AuthenticationType.AzureMFA || connection.authenticationType === Constants.AuthenticationType.AzureMFAAndUser) ? connection.azureAccount ?? connection.userName : connection.userName; - let account = azureAccounts.find(account => account.key.accountId === accountId || account.displayInfo.email === accountId); + let account = azureAccounts.find(account => account.key.accountId === accountId || account.displayInfo.email.toLocaleLowerCase() === accountId.toLocaleLowerCase()); if (account) { this._logService.debug(`Getting security token for Azure account ${account.key.accountId}`); if (account.isStale) {