Email typo check on new addresses: "Did you mean you@gmail.com?" for gmai.com / gmial.com / hotmial.com / outlook.comz / gmail.con etc., and refuse domains that cannot receive mail (no MX/A). Applies only to addresses with no account yet (existing members always sign in), on sign-in/sign-up, password signup and the support form; skipped when the server has no mail key (local QA). DNS errors fail open. Same emailcheck.js in IAP and LinkSpin. Prompted by SendGrid bounces to gmai.com and outlook.comz (2026-10-22).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,10 @@ const auth = require('./auth');
|
||||
const accounts = require('./accounts');
|
||||
const ads = require('./ads');
|
||||
const mailer = require('./mailer');
|
||||
const { emailIssue } = require('./emailcheck'); // typo / no-mail-domain check for NEW addresses (2026-10-22)
|
||||
// only addresses we have never seen get the typo check; existing members always sign in with what they have.
|
||||
// Skipped when this server cannot send mail (local QA copies sign in as @example.com via devCode).
|
||||
const newEmailIssue = async e => (!mailer.hasKey() || (await accounts.byEmail(e)) ? null : emailIssue(e));
|
||||
const messages = require('./messages');
|
||||
const reports = require('./reports');
|
||||
const drip = require('./drip');
|
||||
@@ -1457,6 +1461,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const acct = s && s.email ? await accounts.byEmail(s.email) : null; // signed in: the ticket is theirs, whatever was typed
|
||||
const email = acct ? acct.email : String(b.email || '').trim().toLowerCase();
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email)) return json(res, 400, { error: 'That email address does not look right.' });
|
||||
if (!acct) { const iss = await newEmailIssue(email); if (iss) return json(res, 400, { error: iss.error, suggestion: iss.suggestion }); } // replies must reach them
|
||||
const guard = supportGuard(req, b, email);
|
||||
if (guard) return json(res, guard.status, guard.body);
|
||||
const r = await helpdesk.call('create', { source: 'public', email, name: b.name || (acct && acct.username) || '', username: acct && acct.username, subject: b.subject, category: b.category, body: b.body });
|
||||
@@ -1528,6 +1533,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (!SIGNUPS_OPEN) return json(res, 403, SHUT);
|
||||
const b = await readBody(req);
|
||||
const ref = parseCookies(req)['iap.sponsor'] || ''; // last-touch attribution, locked at account creation
|
||||
{ const iss = await newEmailIssue(String(b.email || '').trim().toLowerCase()); if (iss) return json(res, 400, { error: iss.error, suggestion: iss.suggestion }); }
|
||||
const r = await accounts.signup(b.email, b.password, ref);
|
||||
if (r.error) return json(res, 400, r);
|
||||
{ const lc = parseCookies(req)['ls.click']; if (lc) { postbacks.bindClick(String(b.email || '').trim().toLowerCase(), lc); postbacks.convertFor(String(b.email || '').trim().toLowerCase(), 'join', {}).catch(() => {}); } }
|
||||
@@ -1555,6 +1561,7 @@ const server = http.createServer(async (req, res) => {
|
||||
// closed sign-ups shut the door to NEW accounts only; members already here (incl. imported shells) still get their code
|
||||
const acct0 = await accounts.byEmail(e);
|
||||
if (!SIGNUPS_OPEN && !acct0) return json(res, 403, SHUT);
|
||||
if (!acct0) { const iss = await newEmailIssue(e); if (iss) return json(res, 400, { error: iss.error, suggestion: iss.suggestion }); }
|
||||
if (!isTester(e, acct0)) return json(res, 403, TESTING);
|
||||
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.' }); }
|
||||
|
||||
Reference in New Issue
Block a user