lint, actually cache value

This commit is contained in:
shamoon 2024-05-16 22:03:53 -07:00
parent 1f62e11d88
commit 30d0492c55

View File

@ -12,7 +12,7 @@ const sessionSIDCacheKey = `${proxyName}__sessionSID`;
async function login(widget, service) { async function login(widget, service) {
const url = formatApiCall(widgets[widget.type].api, { ...widget, endpoint: "session" }); const url = formatApiCall(widgets[widget.type].api, { ...widget, endpoint: "session" });
const [status, , , responseHeaders] = await httpProxy(url, { const [, , , responseHeaders] = await httpProxy(url, {
method: "POST", method: "POST",
body: JSON.stringify({ password: widget.password }), body: JSON.stringify({ password: widget.password }),
headers: { headers: {
@ -21,11 +21,12 @@ async function login(widget, service) {
}); });
try { try {
console.log(responseHeaders);
const connectSidCookie = responseHeaders["set-cookie"] const connectSidCookie = responseHeaders["set-cookie"]
.find((cookie) => cookie.startsWith("connect.sid=")) .find((cookie) => cookie.startsWith("connect.sid="))
.split(";")[0] .split(";")[0]
.replace("connect.sid=", ""); .replace("connect.sid=", "");
cache.put(`${sessionSIDCacheKey}.${service}`); cache.put(`${sessionSIDCacheKey}.${service}`, connectSidCookie);
return connectSidCookie; return connectSidCookie;
} catch (e) { } catch (e) {
logger.error(`Error logging into wg-easy`); logger.error(`Error logging into wg-easy`);
@ -52,7 +53,7 @@ export default async function wgeasyProxyHandler(req, res) {
return res.status(500).json({ error: "Failed to authenticate with Wg-Easy" }); return res.status(500).json({ error: "Failed to authenticate with Wg-Easy" });
} }
} }
const [, , data, ] = await httpProxy( const [, , data] = await httpProxy(
formatApiCall(widgets[widget.type].api, { ...widget, endpoint: "wireguard/client" }), formatApiCall(widgets[widget.type].api, { ...widget, endpoint: "wireguard/client" }),
{ {
headers: { headers: {