Fix Jackett widget when using password (#3097)
Fixes the error that occurs as seen in (#437, #1799 and #2794) which occurs due to the way password authentication works in Jackett. We now make a login request to Jackett to get the cookie and then use that cookie to make the actual request to the Jackett API.pull/3125/head
parent
7e0fbed06b
commit
b97d625c93
@ -0,0 +1,22 @@
|
||||
import { httpProxy } from "utils/proxy/http";
|
||||
import { formatApiCall } from "utils/proxy/api-helpers";
|
||||
|
||||
export async function fetchJackettCookie(widget, loginURL) {
|
||||
const url = new URL(formatApiCall(loginURL, widget));
|
||||
const loginData = `password=${encodeURIComponent(widget.password)}`;
|
||||
const [status, , , , params] = await httpProxy(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: loginData,
|
||||
});
|
||||
|
||||
if (status === 200 && params && params.headers && params.headers.Cookie) {
|
||||
const cookieValue = params.headers.Cookie;
|
||||
return cookieValue;
|
||||
} else {
|
||||
logger.error("Failed to fetch Jackett cookie, status: %d", status);
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue