diff --git a/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts b/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts index e0de861e26..afba07b4f3 100644 --- a/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts +++ b/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts @@ -130,7 +130,7 @@ export class CmsConnectionWidget extends ConnectionWidget { this.fillInConnectionForm(authTypeChanged); this.registerListeners(); if (this._authTypeSelectBox) { - this.onAuthTypeSelected(this._authTypeSelectBox.value); + this.onAuthTypeSelected(this._authTypeSelectBox.value, false); } } diff --git a/src/sql/workbench/services/connection/browser/connectionWidget.ts b/src/sql/workbench/services/connection/browser/connectionWidget.ts index af5e6b27d8..ff3b56411b 100644 --- a/src/sql/workbench/services/connection/browser/connectionWidget.ts +++ b/src/sql/workbench/services/connection/browser/connectionWidget.ts @@ -179,7 +179,7 @@ export class ConnectionWidget extends lifecycle.Disposable { this.fillInConnectionForm(authTypeChanged); this.registerListeners(); if (this._authTypeSelectBox) { - this.onAuthTypeSelected(this._authTypeSelectBox.value); + this.onAuthTypeSelected(this._authTypeSelectBox.value, false); } } @@ -553,7 +553,7 @@ export class ConnectionWidget extends lifecycle.Disposable { // Theme styler this._register(styler.attachSelectBoxStyler(this._authTypeSelectBox, this._themeService)); this._register(this._authTypeSelectBox.onDidSelect(selectedAuthType => { - this.onAuthTypeSelected(selectedAuthType.selected); + this.onAuthTypeSelected(selectedAuthType.selected, true); this.setConnectButton(); })); } @@ -613,12 +613,10 @@ export class ConnectionWidget extends lifecycle.Disposable { this._callbacks.onSetConnectButton(shouldEnableConnectButton); } - protected onAuthTypeSelected(selectedAuthType: string): void { + protected onAuthTypeSelected(selectedAuthType: string, clearCredentials: boolean): void { let currentAuthType = this.getMatchingAuthType(selectedAuthType); - if (currentAuthType !== AuthenticationType.SqlLogin) { - if (currentAuthType !== AuthenticationType.AzureMFA && currentAuthType !== AuthenticationType.AzureMFAAndUser) { - this._userNameInputBox.value = ''; - } + if (clearCredentials) { + this._userNameInputBox.value = ''; this._passwordInputBox.value = ''; } this._userNameInputBox.hideMessage(); @@ -915,7 +913,7 @@ export class ConnectionWidget extends lifecycle.Disposable { } if (this._authTypeSelectBox) { - this.onAuthTypeSelected(this._authTypeSelectBox.value); + this.onAuthTypeSelected(this._authTypeSelectBox.value, false); } else { this._tableContainer.classList.remove('hide-username'); this._tableContainer.classList.remove('hide-password');