Handle no matching account scenario (#22908)

This commit is contained in:
Cheena Malhotra
2023-05-01 10:54:42 -07:00
committed by GitHub
parent 24e67a1cbd
commit f4952c76b8

View File

@@ -967,15 +967,18 @@ export class ConnectionWidget extends lifecycle.Disposable {
if (accountName) {
// For backwards compatibility with ADAL, we need to check if the account ID matches with tenant Id or just the account ID
// The OR case can be removed once we no longer support ADAL
account = this._azureAccountList.find(account => account.key.accountId === this.getModelValue(accountName)
account = this._azureAccountList?.find(account => account.key.accountId === this.getModelValue(accountName)
|| account.key.accountId.split('.')[0] === this.getModelValue(accountName));
this._azureAccountDropdown.selectWithOptionName(account.key.accountId);
} else {
if (account) {
this._azureAccountDropdown.selectWithOptionName(account.key.accountId);
}
}
if (!account) {
// If account was not filled in from received configuration, select the first account.
this._azureAccountDropdown.select(0);
account = this._azureAccountList[0];
if (this._azureAccountList.length > 0) {
accountName = account.key.accountId;
accountName = account?.key?.accountId;
} else {
this._logService.debug('fillInConnectionInputs: No accounts available');
}