Closed sign-ups no longer block the email code for members who already have an account (Marty was refused on production)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-07 16:11:09 -05:00
parent 8b0e68fb0d
commit eab7106e65
+2 -1
View File
@@ -1173,10 +1173,11 @@ const server = http.createServer(async (req, res) => {
// -- passwordless: email code sign-in (signup and login are the same act)
if (p === '/api/auth/email/start' && req.method === 'POST') {
if (!SIGNUPS_OPEN) return json(res, 403, SHUT);
const b = await readBody(req);
const e = String(b.email || '').trim().toLowerCase();
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(e)) return json(res, 400, { error: 'That email address does not look right.' });
// closed sign-ups shut the door to NEW accounts only; members already here (incl. imported shells) still get their code
if (!SIGNUPS_OPEN && !(await accounts.byEmail(e))) return json(res, 403, SHUT);
const prev = emailCodes.get(e);
if (prev && Date.now() < prev.nextAt) { console.log('signup-guard cooldown', clientIp(req), e.replace(/^(.).*(@.*)$/, '$1***$2')); return json(res, 429, { error: 'Code already sent. Give it a minute, then try again.' }); }
const guard = codeGuard(req, b); // honeypot, form age, per-IP + global limits, icon check once limited