mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-13 16:30:31 +00:00
fix(widgets): move flood auth from BASIC to raw json body
This commit is contained in:
parent
7087ed80cc
commit
8a84eba232
1 changed files with 12 additions and 7 deletions
|
@ -8,14 +8,19 @@ const logger = createLogger("floodProxyHandler");
|
||||||
async function login(widget) {
|
async function login(widget) {
|
||||||
logger.debug("flood is rejecting the request, logging in.");
|
logger.debug("flood is rejecting the request, logging in.");
|
||||||
const loginUrl = new URL(`${widget.url}/api/auth/authenticate`).toString();
|
const loginUrl = new URL(`${widget.url}/api/auth/authenticate`).toString();
|
||||||
const loginHeaders = {
|
|
||||||
"Accept-Encoding": "application/json"
|
|
||||||
};
|
|
||||||
if (widget.username && widget.password) {
|
|
||||||
loginHeaders.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const loginParams = { method: "POST", loginHeaders };
|
const loginParams = {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: null
|
||||||
|
};
|
||||||
|
|
||||||
|
if (widget.username && widget.password) {
|
||||||
|
loginParams.body = JSON.stringify({
|
||||||
|
"username": widget.username,
|
||||||
|
"password": widget.password
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const [status, contentType, data] = await httpProxy(loginUrl, loginParams);
|
const [status, contentType, data] = await httpProxy(loginUrl, loginParams);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue