Fix missing password in Connection pane for Server connections with remembered passwords (#21813)

* Fix missing password in Connection pane

* Get saved password for SQL login default auth type

* Clean up

* Fix build hygiene errors

* Captures input

* Add timeout waiting for all promises to resolve

* Add missing semicolon

* Code review feedback

* Minor clean up

* Code review feedback

* Improved error messaging

* Update src/sql/workbench/services/connection/browser/connectionDialogService.ts

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>

* Improves UX around loading passwords

* Remove unused import

* Uses await instead of promise chaining.

* Removes async

* Revert back to resolving password promise.

* Asserts controller map and model have values.

---------

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
This commit is contained in:
Lewis Sanchez
2023-02-14 20:49:55 -08:00
committed by GitHub
parent a683b1b777
commit d9b24522e5
3 changed files with 44 additions and 12 deletions

View File

@@ -44,6 +44,7 @@ import { createCSSRule } from 'vs/base/browser/dom';
const ConnectionStringText = localize('connectionWidget.connectionString', "Connection string");
export class ConnectionWidget extends lifecycle.Disposable {
private _initialConnectionInfo: IConnectionProfile;
private _defaultInputOptionRadioButton: RadioButton;
private _connectionStringRadioButton: RadioButton;
private _previousGroupOption: string;
@@ -612,7 +613,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
this._callbacks.onSetConnectButton(shouldEnableConnectButton);
}
protected onAuthTypeSelected(selectedAuthType: string) {
protected onAuthTypeSelected(selectedAuthType: string): void {
let currentAuthType = this.getMatchingAuthType(selectedAuthType);
if (currentAuthType !== AuthenticationType.SqlLogin) {
if (currentAuthType !== AuthenticationType.AzureMFA && currentAuthType !== AuthenticationType.AzureMFAAndUser) {
@@ -668,6 +669,16 @@ export class ConnectionWidget extends lifecycle.Disposable {
this._userNameInputBox.enable();
this._passwordInputBox.enable();
this._rememberPasswordCheckBox.enabled = true;
this._initialConnectionInfo.authenticationType = AuthenticationType.SqlLogin;
if (this._initialConnectionInfo && this._initialConnectionInfo.userName) {
const setPasswordInputBox = (profile: IConnectionProfile) => {
this._passwordInputBox.value = profile.password;
};
this._rememberPasswordCheckBox.checked = this._initialConnectionInfo.savePassword;
this._connectionManagementService.addSavedPassword(this._initialConnectionInfo, true).then(setPasswordInputBox)
}
}
}
@@ -822,6 +833,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
}
public initDialog(connectionInfo: IConnectionProfile): void {
this._initialConnectionInfo = connectionInfo;
this.fillInConnectionInputs(connectionInfo);
}