mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-15 02:48:30 -05:00
Handle default tenant to be set when only 1 tenant exists (#21532)
This commit is contained in:
@@ -146,6 +146,7 @@ export class AzureAccountProvider implements azdata.AccountProvider, vscode.Disp
|
||||
if (azureAuth) {
|
||||
Logger.pii(`Getting account security token for ${JSON.stringify(account.key)} (tenant ${tenantId}). Auth Method = ${azureAuth.userFriendlyName}`, [], []);
|
||||
if (this.authLibrary === Constants.AuthLibrary.MSAL) {
|
||||
tenantId = tenantId || account.properties.owningTenant.id;
|
||||
let authResult = await azureAuth.getTokenMsal(account.key.accountId, resource, tenantId);
|
||||
if (!authResult || !authResult.account || !authResult.account.idTokenClaims) {
|
||||
Logger.error(`MSAL: getToken call failed`);
|
||||
|
||||
@@ -689,6 +689,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._azureTenantId = selectedAccount.properties.tenants[0].id;
|
||||
this.onAzureTenantSelected(0);
|
||||
}
|
||||
|
||||
@@ -860,6 +861,13 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
}
|
||||
this.onAzureTenantSelected(this._azureTenantDropdown.values.indexOf(this._azureTenantDropdown.value));
|
||||
}
|
||||
else if (account && account.properties.tenants && account.properties.tenants.length === 1) {
|
||||
this._azureTenantId = account.properties.tenants[0].id;
|
||||
this.onAzureTenantSelected(0);
|
||||
}
|
||||
else {
|
||||
this._logService.error(`fillInConnectionInputs : Could not find any tenants for account ${accountName}`);
|
||||
}
|
||||
}).catch(err => this._logService.error(`Unexpected error populating initial Azure Account options : ${err}`));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user