From d85bf4f6dd3125db88e07ee430cedd0cb52c225e Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Wed, 12 Sep 2018 13:32:40 -0700 Subject: [PATCH] fix the account not found error when creating firewall rules (#2543) --- .../workbench/api/node/extHostAccountManagement.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/sql/workbench/api/node/extHostAccountManagement.ts b/src/sql/workbench/api/node/extHostAccountManagement.ts index c838220ba6..c74cf6c530 100644 --- a/src/sql/workbench/api/node/extHostAccountManagement.ts +++ b/src/sql/workbench/api/node/extHostAccountManagement.ts @@ -90,14 +90,16 @@ export class ExtHostAccountManagement extends ExtHostAccountManagementShape { } public $getSecurityToken(account: sqlops.Account): Thenable<{}> { - for (const handle in this._accounts) { - const providerHandle = parseInt(handle); - if (this._accounts[handle].findIndex((acct) => acct.key.accountId === account.key.accountId) !== -1) { - return this._withProvider(providerHandle, (provider: sqlops.AccountProvider) => provider.getSecurityToken(account)); + return this.$getAllAccounts().then(() => { + for (const handle in this._accounts) { + const providerHandle = parseInt(handle); + if (this._accounts[handle].findIndex((acct) => acct.key.accountId === account.key.accountId) !== -1) { + return this._withProvider(providerHandle, (provider: sqlops.AccountProvider) => provider.getSecurityToken(account)); + } } - } - throw new Error(`Account ${account.key.accountId} not found.`); + throw new Error(`Account ${account.key.accountId} not found.`); + }); } public get onDidChangeAccounts(): Event {