diff options
Diffstat (limited to 'routes/users.ts')
| -rw-r--r-- | routes/users.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/routes/users.ts b/routes/users.ts index 17bf5026..cfa41b8b 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -11,6 +11,7 @@ import { mail, templates } from "$lib/mail"; import { getNostrUser, getProfile, serverPubkey2 } from "$lib/nostr"; import deleteUser from "$lib/deluser"; import register from "$lib/register"; +import { allowTorRegistration } from "$lib/registration-limit"; import { assertNameFree } from "$lib/names"; import { isReserved } from "$lib/reserved"; import { emit } from "$lib/sockets"; @@ -47,8 +48,7 @@ const verifyRecaptcha = async ( if (!secret) return true; // Skip captcha for Tor users accessing via .onion - const reqHost = req?.headers?.["x-forwarded-host"] || req?.headers?.["host"] || ""; - if (reqHost.endsWith(".onion")) return true; + if (req?.isTor) return true; // Skip captcha for allowlisted User-Agents (prefix match) const uaRaw = req?.headers?.["user-agent"] || req?.headers?.["User-Agent"]; @@ -194,6 +194,7 @@ export default { try { const ip = headers["cf-connecting-ip"]; if (!body.user) fail("no user object provided"); + if (!(await allowTorRegistration(req, res))) return; let { user } = body; // Per-IP registration cap. Nothing else throttles /register (the @@ -679,6 +680,7 @@ export default { let user = await getUser(key); if (!user) { + if (!(await allowTorRegistration(req, res))) return; const k0 = await getProfile(key); let username = k0?.name?.replace(/[^a-zA-Z0-9 ]/g, ""); const exists = await getUser(username); |
