diff --git a/server.js b/server.js index f997a9f..29aae0d 100644 --- a/server.js +++ b/server.js @@ -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