fix: threshold was not being properly computed, proxy properly checks if login token exists within login call.

This commit is contained in:
ConnerWithAnE 2024-06-03 15:26:49 -06:00
parent 19c3ac0d7e
commit 941d2f1c00
2 changed files with 6 additions and 2 deletions

View File

@ -28,7 +28,7 @@ export default function Component({ service }) {
const enabled = infoData.filter((item) => item.enabled).length;
const disabled = infoData.length - enabled;
const connectionThreshold = widget.threshold ?? 2 * 60 * 1000;
const connectionThreshold = (widget.threshold ?? 2) * 60 * 1000;
const currentTime = new Date();
const connected = infoData.filter(
(item) => currentTime - new Date(item.latestHandshakeAt) < connectionThreshold,

View File

@ -21,6 +21,10 @@ async function login(widget, service) {
});
try {
const sid = cache.get(`${sessionSIDCacheKey}.${service}`);
if (sid) {
return sid;
}
const connectSidCookie = responseHeaders["set-cookie"]
.find((cookie) => cookie.startsWith("connect.sid="))
.split(";")[0]
@ -28,7 +32,7 @@ async function login(widget, service) {
cache.put(`${sessionSIDCacheKey}.${service}`, connectSidCookie);
return connectSidCookie;
} catch (e) {
logger.error(`Error logging into wg-easy`);
logger.error(`Error logging into wg-easy, error: ${e}`);
cache.del(`${sessionSIDCacheKey}.${service}`);
return null;
}