mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
deluge doesnt use username
This commit is contained in:
parent
04fbf315ee
commit
c9f508d321
@ -13,8 +13,8 @@ const dataParams = [
|
|||||||
];
|
];
|
||||||
const loginMethod = "auth.login";
|
const loginMethod = "auth.login";
|
||||||
|
|
||||||
async function sendRpc(url, method, params, username, password) {
|
async function sendRpc(url, method, params) {
|
||||||
const [status, contentType, data] = await sendJsonRpcRequest(url, method, params, username, password);
|
const [status, contentType, data] = await sendJsonRpcRequest(url, method, params);
|
||||||
const json = JSON.parse(data.toString());
|
const json = JSON.parse(data.toString());
|
||||||
if (json?.error) {
|
if (json?.error) {
|
||||||
if (json.error.code === 1) {
|
if (json.error.code === 1) {
|
||||||
@ -26,8 +26,8 @@ async function sendRpc(url, method, params, username, password) {
|
|||||||
return [status, contentType, data];
|
return [status, contentType, data];
|
||||||
}
|
}
|
||||||
|
|
||||||
function login(url, username, password) {
|
function login(url, password) {
|
||||||
return sendRpc(url, loginMethod, [password], username, password);
|
return sendRpc(url, loginMethod, [password]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function delugeProxyHandler(req, res) {
|
export default async function delugeProxyHandler(req, res) {
|
||||||
@ -48,15 +48,15 @@ export default async function delugeProxyHandler(req, res) {
|
|||||||
const api = widgets?.[widget.type]?.api
|
const api = widgets?.[widget.type]?.api
|
||||||
const url = new URL(formatApiCall(api, { ...widget }));
|
const url = new URL(formatApiCall(api, { ...widget }));
|
||||||
|
|
||||||
let [status, contentType, data] = await sendRpc(url, dataMethod, dataParams, widget.username, widget.password);
|
let [status, contentType, data] = await sendRpc(url, dataMethod, dataParams);
|
||||||
if (status === 403) {
|
if (status === 403) {
|
||||||
[status, contentType, data] = await login(url, widget.username, widget.password);
|
[status, contentType, data] = await login(url, widget.password);
|
||||||
if (status !== 200) {
|
if (status !== 200) {
|
||||||
return res.status(status).end(data);
|
return res.status(status).end(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
[status, contentType, data] = await sendRpc(url, dataMethod, dataParams, widget.username, widget.password);
|
[status, contentType, data] = await sendRpc(url, dataMethod, dataParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(status).end(data);
|
return res.status(status).end(data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user