fix(widgets): move flood auth from BASIC to raw json body

pull/598/head
JigSawFr 2 years ago
parent 7087ed80cc
commit 8a84eba232
No known key found for this signature in database
GPG Key ID: B05E2971A9D6698D

@ -8,15 +8,20 @@ const logger = createLogger("floodProxyHandler");
async function login(widget) {
logger.debug("flood is rejecting the request, logging in.");
const loginUrl = new URL(`${widget.url}/api/auth/authenticate`).toString();
const loginHeaders = {
"Accept-Encoding": "application/json"
const loginParams = {
method: "POST",
headers: { "Content-Type": "application/json" },
body: null
};
if (widget.username && widget.password) {
loginHeaders.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`
loginParams.body = JSON.stringify({
"username": widget.username,
"password": widget.password
});
}
const loginParams = { method: "POST", loginHeaders };
// eslint-disable-next-line no-unused-vars
const [status, contentType, data] = await httpProxy(loginUrl, loginParams);
return [status, data];

Loading…
Cancel
Save