Pre-populate username for selected user account (AzureMFAAndUser) (#22126)

This commit is contained in:
Cheena Malhotra
2023-03-03 12:11:52 -08:00
committed by GitHub
parent 9ea3889170
commit 19d77f02dd

View File

@@ -646,6 +646,10 @@ export class ConnectionWidget extends lifecycle.Disposable {
// Populate tenants (select first by default for initialization of tenant dialog)
await this.onAzureAccountSelected(true);
this._azureTenantDropdown.enable();
// Populate username as 'email' of selected azure account in dropdown, as username is required,
// and email of Azure account selected applies as username in most cases.
this._userNameInputBox.value = this._azureAccountList.find(a => a.displayInfo.displayName === this._azureAccountDropdown.value)?.displayInfo.email!
?? this._azureAccountList[0]?.displayInfo?.email ?? '';
}).catch(err => this._logService.error(`Unexpected error populating Azure Account dropdown : ${err}`));
// Immediately show/hide appropriate elements though so user gets immediate feedback while we load accounts
this._tableContainer.classList.remove('hide-username');
@@ -757,6 +761,13 @@ export class ConnectionWidget extends lifecycle.Disposable {
if (!selectedAccount && selectFirstByDefault && this._azureAccountList.length > 0) {
selectedAccount = this._azureAccountList[0];
}
if (this.authenticationType === AuthenticationType.AzureMFAAndUser) {
// Populate username as 'email' of selected azure account in dropdown, as username is required,
// and email of Azure account selected applies as username in most cases.
this._userNameInputBox.value = selectedAccount?.displayInfo?.email! ?? '';
}
if (selectedAccount && selectedAccount.properties.tenants && selectedAccount.properties.tenants.length > 1) {
// There are multiple tenants available so let the user select one
let options = selectedAccount.properties.tenants.map(tenant => tenant.displayName);