
Dropping Email Required — Migrating to Phone OR Email Authentication
Background While building an internal e-commerce site, I put an email required constraint on the registration form from day one. The reason was simple: authentication = email was my unconscious assumption. Then reality hit. Most existing users only had phone numbers. Specifically, users registered via LINE only had phone numbers in the database — no email addresses. When they tried to register, they got a Bad Request error. The Problem Structure The frontend (React) sends phone number + password. The backend (Node.js/TypeScript) looks up users by phone number, but users with email as required field = unset were not processed correctly. Worse, when a phone number was submitted for new registration but already existed in the DB, it tried to create a new record and hit a Unique constraint violation. Two problems: Registration: email as required field causes validation to reject phone-only users Registration: attempting to create a new user with an existing phone number causes Unique error
Continue reading on Dev.to React
Opens in a new tab

