Merge pull request #3325 from hardillb/http-basic-username-only

Fix basic auth with empty username or password
This commit is contained in:
Nick O'Leary 2022-01-10 18:27:55 +00:00 committed by GitHub
commit 062f76214e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -302,6 +302,8 @@ in your Node-RED user directory (${RED.settings.userDir}).
// var cred = ""
if (this.credentials.user || this.credentials.password) {
// cred = `${this.credentials.user}:${this.credentials.password}`;
if (this.credentials.user === undefined) { this.credentials.user = ""}
if (this.credentials.password === undefined) { this.credentials.password = ""}
opts.headers.Authorization = "Basic " + Buffer.from(`${this.credentials.user}:${this.credentials.password}`).toString("base64");
}
// build own basic auth header