mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 01:25:38 -05:00
Prevent reconnects for mssql provider (#22825)
This commit is contained in:
@@ -57,6 +57,7 @@ import { VIEWLET_ID as ExtensionsViewletID } from 'vs/workbench/contrib/extensio
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IErrorDiagnosticsService } from 'sql/workbench/services/diagnostics/common/errorDiagnosticsService';
|
||||
import { PasswordChangeDialog } from 'sql/workbench/services/connection/browser/passwordChangeDialog';
|
||||
import { enableSqlAuthenticationProviderConfig, mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
|
||||
export class ConnectionManagementService extends Disposable implements IConnectionManagementService {
|
||||
|
||||
@@ -1141,6 +1142,12 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
|
||||
// We expect connectionProfile to be defined
|
||||
if (connectionProfile && connectionProfile.authenticationType === Constants.AuthenticationType.AzureMFA) {
|
||||
// We do not need to reconnect for MSSQL Provider, if 'SQL Authentication Provider' setting is enabled.
|
||||
// Update the token in case it needs refreshing/reauthentication.
|
||||
if (connectionProfile.providerName === mssqlProviderName && this.getEnableSqlAuthenticationProviderConfig()) {
|
||||
await this.fillInOrClearToken(connectionProfile);
|
||||
return true;
|
||||
}
|
||||
const expiry = connectionProfile.options.expiresOn;
|
||||
if (typeof expiry === 'number' && !Number.isNaN(expiry)) {
|
||||
const currentTime = new Date().getTime() / 1000;
|
||||
@@ -1172,8 +1179,13 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private getEnableSqlAuthenticationProviderConfig(): boolean {
|
||||
return this._configurationService.getValue(enableSqlAuthenticationProviderConfig) ?? true;
|
||||
}
|
||||
|
||||
// Request Senders
|
||||
@@ -1598,10 +1610,9 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
}
|
||||
|
||||
public async listDatabases(connectionUri: string): Promise<azdata.ListDatabasesResult | undefined> {
|
||||
const self = this;
|
||||
await this.refreshAzureAccountTokenIfNecessary(connectionUri);
|
||||
if (self.isConnected(connectionUri)) {
|
||||
return self.sendListDatabasesRequest(connectionUri);
|
||||
if (this.isConnected(connectionUri)) {
|
||||
return this.sendListDatabasesRequest(connectionUri);
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user