Remove unusable tenants (#9921)

This commit is contained in:
Amir Omidi
2020-04-09 13:01:24 -07:00
committed by GitHub
parent 23f1a08aa0
commit 510c12677e

View File

@@ -219,12 +219,14 @@ export abstract class AzureAuth implements vscode.Disposable {
console.log('Base token was empty, account is stale.'); console.log('Base token was empty, account is stale.');
return undefined; return undefined;
} }
try { try {
await this.refreshAccessToken(account.key, baseToken.refreshToken, tenant, resource); await this.refreshAccessToken(account.key, baseToken.refreshToken, tenant, resource);
} catch (ex) { } catch (ex) {
console.log(ex); console.log(`Could not refresh access token for ${JSON.stringify(tenant)} - silently removing the tenant from the user's account.`);
account.isStale = true; azureAccount.properties.tenants = azureAccount.properties.tenants.filter(t => t.id !== tenant.id);
return undefined; console.log(ex, ex?.data, ex?.response);
continue;
} }
cachedTokens = await this.getCachedToken(account.key, resource.id, tenant.id); cachedTokens = await this.getCachedToken(account.key, resource.id, tenant.id);
@@ -243,9 +245,12 @@ export abstract class AzureAuth implements vscode.Disposable {
if (azureAccount.properties.subscriptions) { if (azureAccount.properties.subscriptions) {
azureAccount.properties.subscriptions.forEach(subscription => { azureAccount.properties.subscriptions.forEach(subscription => {
response[subscription.id] = { // Make sure that tenant has information populated.
...response[subscription.tenantId] if (response[subscription.tenantId]) {
}; response[subscription.id] = {
...response[subscription.tenantId]
};
}
}); });
} }