mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-02 13:33:40 +01:00
fix(widgets): move flood auth from BASIC to raw json body
This commit is contained in:
parent
7087ed80cc
commit
8a84eba232
@ -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…
x
Reference in New Issue
Block a user