From 0ad6c9ec8a4f91e1d45af4a76330cc3ddcf177a2 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 4 Feb 2026 22:53:22 +0000 Subject: whitelist ua's --- routes/users.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/routes/users.ts b/routes/users.ts index 37dd2d7f..4f1cb487 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -34,6 +34,17 @@ const verifyRecaptcha = async (response, req?) => { const host = req?.headers?.["host"] || ""; if (host.endsWith(".onion")) return true; + // Skip captcha for allowlisted User-Agents (prefix match) + const uaRaw = req?.headers?.["user-agent"] || req?.headers?.["User-Agent"]; + const ua = Array.isArray(uaRaw) ? uaRaw[0] : uaRaw; + if (typeof ua === "string") { + const prefixes = await db.sMembers("nocaptcha_ua"); + const uaLower = ua.toLowerCase(); + if (prefixes.some((p) => uaLower.startsWith(p.toLowerCase()))) { + return true; + } + } + // Check for valid API key to bypass captcha const apiKey = req?.headers?.["x-api-key"]; if (apiKey && (await db.sIsMember("apikeys", apiKey))) { -- cgit v1.2.3