mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
Fix encodeBase64
for empty password or user in HTTP Basic Authentication (#4326)
This commit is contained in:
parent
f1e2ee74ea
commit
458cdf9f9b
1 changed files with 3 additions and 1 deletions
|
@ -230,10 +230,12 @@ class Monitor extends BeanModel {
|
||||||
/**
|
/**
|
||||||
* Encode user and password to Base64 encoding
|
* Encode user and password to Base64 encoding
|
||||||
* for HTTP "basic" auth, as per RFC-7617
|
* for HTTP "basic" auth, as per RFC-7617
|
||||||
|
* @param {string|null} user - The username (nullable if not changed by a user)
|
||||||
|
* @param {string|null} pass - The password (nullable if not changed by a user)
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
encodeBase64(user, pass) {
|
encodeBase64(user, pass) {
|
||||||
return Buffer.from(user + ":" + pass).toString("base64");
|
return Buffer.from(`${user || ""}:${pass || ""}`).toString("base64");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue