Skip to content

Commit bf2d52c

Browse files
Merge pull request #617 from gjsjohnmurray/fix-616
fix #616 Avoid prompting for password that is already saved
2 parents 8729450 + dbead6e commit bf2d52c

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/api/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,14 @@ export class AtelierAPI {
287287
let authRequest = authRequestMap.get(target);
288288
if (cookies.length || method === "HEAD") {
289289
auth = Promise.resolve(cookies);
290-
headers["Authorization"] = `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`;
290+
291+
// Only send basic authorization if username and password specified (including blank, for unauthenticated access)
292+
if (typeof username === "string" && typeof password === "string") {
293+
headers["Authorization"] = `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`;
294+
}
291295
} else if (!cookies.length) {
292296
if (!authRequest) {
297+
// Recursion point
293298
authRequest = this.request(0, "HEAD");
294299
authRequestMap.set(target, authRequest);
295300
}

src/extension.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,15 +488,30 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
488488
await checkConnection(true, uri);
489489
}
490490

491-
vscode.workspace.onDidChangeWorkspaceFolders(({ added, removed }) => {
491+
vscode.workspace.onDidChangeWorkspaceFolders(async ({ added, removed }) => {
492492
const folders = vscode.workspace.workspaceFolders;
493+
494+
// Make sure we have a resolved connection spec for the targets of all added folders
495+
const toCheck = new Map<string, vscode.Uri>();
496+
added.map((workspaceFolder) => {
497+
const uri = workspaceFolder.uri;
498+
const { configName } = connectionTarget(uri);
499+
toCheck.set(configName, uri);
500+
});
501+
for await (const oneToCheck of toCheck) {
502+
const configName = oneToCheck[0];
503+
const uri = oneToCheck[1];
504+
const serverName = uri.scheme === "file" ? config("conn", configName).server : configName;
505+
await resolveConnectionSpec(serverName);
506+
}
507+
508+
// If it was just the addition of the first folder, and this is one of the isfs types, hide the ObjectScript Explorer for this workspace
493509
if (
494510
folders?.length === 1 &&
495511
added?.length === 1 &&
496512
removed?.length === 0 &&
497513
filesystemSchemas.includes(added[0].uri.scheme)
498514
) {
499-
// First folder has been added and is one of the isfs types, so hide the ObjectScript Explorer for this workspace
500515
vscode.workspace
501516
.getConfiguration("objectscript")
502517
.update("showExplorer", false, vscode.ConfigurationTarget.Workspace);

0 commit comments

Comments
 (0)