
How We Let Users Register with Just a Phone Number on a NOT NULL Email Column
How We Let Users Register with Just a Phone Number on a NOT NULL Email Column When we bolted a shop frontend onto an existing ERP system, we hit a quiet but annoying authentication problem. The user table's email column was NOT NULL + UNIQUE . The ERP managed accounts by email. But the shop's target users were wholesale buyers—people who live on their phones and LINE. Many don't have an email address, or at least don't want to type one into a registration form. The solution: placeholder emails . System Architecture ERP Backend (Node.js + TypeScript) └─ User model: email (unique, not null), phone, name, role └─ /api/shop/auth/register ← called by Shop └─ /api/shop/auth/login Shop Frontend (React + TypeScript) └─ Register.tsx: phone + name + password (email optional) └─ Login.tsx: phone + password The shop and ERP share the same User table. ERP users have role: 'staff' or 'admin' ; shop customers get role: 'customer' . Backend: Sneaking Past the Constraint with Placeholder Emails The cor
Continue reading on Dev.to
Opens in a new tab


