refactor: revert credentialed.js
This commit is contained in:
parent
273a05b5ec
commit
c9e9b9692f
@ -34,8 +34,9 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
"ghostfolio",
|
"ghostfolio",
|
||||||
"truenas",
|
"truenas",
|
||||||
"pterodactyl",
|
"pterodactyl",
|
||||||
].includes(widget.type)) {
|
].includes(widget.type))
|
||||||
headers.Authorization = `Bearer ${widget.key}`;
|
{
|
||||||
|
headers.Authorization = `Bearer ${widget.key}`;
|
||||||
} else if (widget.type === "proxmox") {
|
} else if (widget.type === "proxmox") {
|
||||||
headers.Authorization = `PVEAPIToken=${widget.username}=${widget.password}`;
|
headers.Authorization = `PVEAPIToken=${widget.username}=${widget.password}`;
|
||||||
} else if (widget.type === "proxmoxbackupserver") {
|
} else if (widget.type === "proxmoxbackupserver") {
|
||||||
@ -53,20 +54,6 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
} else {
|
} else {
|
||||||
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
||||||
}
|
}
|
||||||
} else if (widget.type === "freshrss") {
|
|
||||||
const resp = await fetch(`${widget.url}/api/greader.php/accounts/ClientLogin`, {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/x-www-form-urlencoded"
|
|
||||||
},
|
|
||||||
body: new URLSearchParams({
|
|
||||||
Email: widget.username,
|
|
||||||
Passwd: widget.password,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
const text = await resp.text()
|
|
||||||
const [, token] = text.split("\n").find(line => line.startsWith("Auth=")).split("=")
|
|
||||||
headers.Authorization = `GoogleLogin auth=${token}`
|
|
||||||
} else {
|
} else {
|
||||||
headers["X-API-Key"] = `${widget.key}`;
|
headers["X-API-Key"] = `${widget.key}`;
|
||||||
}
|
}
|
||||||
@ -94,7 +81,7 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
|
|
||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
if (!validateWidgetData(widget, endpoint, resultData)) {
|
if (!validateWidgetData(widget, endpoint, resultData)) {
|
||||||
return res.status(500).json({ error: { message: "Invalid data", url: sanitizeErrorURL(url), data: resultData } });
|
return res.status(500).json({error: {message: "Invalid data", url: sanitizeErrorURL(url), data: resultData}});
|
||||||
}
|
}
|
||||||
if (map) resultData = map(resultData);
|
if (map) resultData = map(resultData);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user