Fixes clearing of username/password on auth type change (#22138)

This commit is contained in:
Cheena Malhotra
2023-03-03 12:45:09 -08:00
committed by GitHub
parent 19d77f02dd
commit 0ac6f40559
2 changed files with 7 additions and 9 deletions

View File

@@ -130,7 +130,7 @@ export class CmsConnectionWidget extends ConnectionWidget {
this.fillInConnectionForm(authTypeChanged); this.fillInConnectionForm(authTypeChanged);
this.registerListeners(); this.registerListeners();
if (this._authTypeSelectBox) { if (this._authTypeSelectBox) {
this.onAuthTypeSelected(this._authTypeSelectBox.value); this.onAuthTypeSelected(this._authTypeSelectBox.value, false);
} }
} }

View File

@@ -179,7 +179,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
this.fillInConnectionForm(authTypeChanged); this.fillInConnectionForm(authTypeChanged);
this.registerListeners(); this.registerListeners();
if (this._authTypeSelectBox) { 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 // Theme styler
this._register(styler.attachSelectBoxStyler(this._authTypeSelectBox, this._themeService)); this._register(styler.attachSelectBoxStyler(this._authTypeSelectBox, this._themeService));
this._register(this._authTypeSelectBox.onDidSelect(selectedAuthType => { this._register(this._authTypeSelectBox.onDidSelect(selectedAuthType => {
this.onAuthTypeSelected(selectedAuthType.selected); this.onAuthTypeSelected(selectedAuthType.selected, true);
this.setConnectButton(); this.setConnectButton();
})); }));
} }
@@ -613,12 +613,10 @@ export class ConnectionWidget extends lifecycle.Disposable {
this._callbacks.onSetConnectButton(shouldEnableConnectButton); this._callbacks.onSetConnectButton(shouldEnableConnectButton);
} }
protected onAuthTypeSelected(selectedAuthType: string): void { protected onAuthTypeSelected(selectedAuthType: string, clearCredentials: boolean): void {
let currentAuthType = this.getMatchingAuthType(selectedAuthType); let currentAuthType = this.getMatchingAuthType(selectedAuthType);
if (currentAuthType !== AuthenticationType.SqlLogin) { if (clearCredentials) {
if (currentAuthType !== AuthenticationType.AzureMFA && currentAuthType !== AuthenticationType.AzureMFAAndUser) {
this._userNameInputBox.value = ''; this._userNameInputBox.value = '';
}
this._passwordInputBox.value = ''; this._passwordInputBox.value = '';
} }
this._userNameInputBox.hideMessage(); this._userNameInputBox.hideMessage();
@@ -915,7 +913,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
} }
if (this._authTypeSelectBox) { if (this._authTypeSelectBox) {
this.onAuthTypeSelected(this._authTypeSelectBox.value); this.onAuthTypeSelected(this._authTypeSelectBox.value, false);
} else { } else {
this._tableContainer.classList.remove('hide-username'); this._tableContainer.classList.remove('hide-username');
this._tableContainer.classList.remove('hide-password'); this._tableContainer.classList.remove('hide-password');