mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-29 09:35:38 -05:00
Fix BDC remember password and reprompting connection (#7957)
* Fix remember password and reprompting connection * comment * Fix to remember password for session * Fix floating promises
This commit is contained in:
@@ -45,7 +45,7 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
||||
return this.root.getChildren();
|
||||
}
|
||||
|
||||
this.loadSavedControllers();
|
||||
await this.loadSavedControllers();
|
||||
return [new LoadingControllerNode()];
|
||||
}
|
||||
|
||||
@@ -57,7 +57,15 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
||||
this._onDidChangeTreeData.fire(node);
|
||||
}
|
||||
|
||||
public addController(
|
||||
/**
|
||||
* Creates or updates a node in the tree with the specified connection information
|
||||
* @param url The URL for the BDC management endpoint
|
||||
* @param auth The type of auth to use
|
||||
* @param username The username (if basic auth)
|
||||
* @param password The password (if basic auth)
|
||||
* @param rememberPassword Whether to store the password in the password store when saving
|
||||
*/
|
||||
public addOrUpdateController(
|
||||
url: string,
|
||||
auth: AuthType,
|
||||
username: string,
|
||||
@@ -65,7 +73,7 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
||||
rememberPassword: boolean
|
||||
): void {
|
||||
this.removeNonControllerNodes();
|
||||
this.root.addControllerNode(url, auth, username, password, rememberPassword);
|
||||
this.root.addOrUpdateControllerNode(url, auth, username, password, rememberPassword);
|
||||
this.notifyNodeChanged();
|
||||
}
|
||||
|
||||
@@ -113,7 +121,7 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
||||
this.root.clearChildren();
|
||||
let controllers: IControllerInfoSlim[] = this.memento.get('controllers');
|
||||
if (controllers) {
|
||||
for (let c of controllers) {
|
||||
for (const c of controllers) {
|
||||
let password = undefined;
|
||||
if (c.rememberPassword) {
|
||||
password = await this.getPassword(c.url, c.username);
|
||||
@@ -138,18 +146,18 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
||||
}
|
||||
|
||||
public async saveControllers(): Promise<void> {
|
||||
let controllers = this.root.children.map((e): IControllerInfoSlim => {
|
||||
let controller = e as ControllerNode;
|
||||
const controllers = this.root.children.map((e): IControllerInfoSlim => {
|
||||
const controller = e as ControllerNode;
|
||||
return {
|
||||
url: controller.url,
|
||||
auth: controller.auth,
|
||||
username: controller.username,
|
||||
password: controller.password,
|
||||
rememberPassword: !!controller.rememberPassword
|
||||
rememberPassword: controller.rememberPassword
|
||||
};
|
||||
});
|
||||
|
||||
let controllersWithoutPassword = controllers.map((e): IControllerInfoSlim => {
|
||||
const controllersWithoutPassword = controllers.map((e): IControllerInfoSlim => {
|
||||
return {
|
||||
url: e.url,
|
||||
auth: e.auth,
|
||||
@@ -164,7 +172,7 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
||||
showErrorMessage(error);
|
||||
}
|
||||
|
||||
for (let e of controllers) {
|
||||
for (const e of controllers) {
|
||||
if (e.rememberPassword) {
|
||||
await this.savePassword(e.url, e.username, e.password);
|
||||
} else {
|
||||
@@ -187,7 +195,7 @@ export class ControllerTreeDataProvider implements vscode.TreeDataProvider<TreeN
|
||||
return result;
|
||||
}
|
||||
|
||||
private async getPassword(url: string, username: string): Promise<string> {
|
||||
private async getPassword(url: string, username: string): Promise<string | undefined> {
|
||||
let provider = await this.getCredentialProvider();
|
||||
let id = this.createId(url, username);
|
||||
let credential = await provider.readCredential(id);
|
||||
|
||||
Reference in New Issue
Block a user