NestJS Auth Refactor: Adding Username Sign-In and Multi-Identifier Lookup
A developer refactored a NestJS authentication project built with brkpt-auth to support a unique username field alongside email for user sign-in. The Prisma schema and data transfer objects were updated so users can register with both a username and email, and sign in using either identifier. The findUserByDto adapter method was modified to query the database against both fields, preventing duplicate registrations on either value. A known security gap was flagged: combining unverified email registration with OAuth can allow one user's credentials account to be hijacked when the real email owner later signs in via Google. The post deliberately omits email verification to stay focused on the identifier and schema changes demonstrated.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in