Skip to content

fix(auth): verify passwords on login and add claim flow for orphan ac…#75

Open
sarahhashash wants to merge 1 commit into
mainfrom
fix/auth-login-password-verification
Open

fix(auth): verify passwords on login and add claim flow for orphan ac…#75
sarahhashash wants to merge 1 commit into
mainfrom
fix/auth-login-password-verification

Conversation

@sarahhashash
Copy link
Copy Markdown
Contributor

…counts

The /api/auth/login route was upserting users by email and issuing a session without ever checking the supplied password. Two problems:

  1. Anyone who knew an email could sign in as that user.
  2. Every email ever typed into the form became a real User row, with passwordHash = NULL.

Login now does a findUnique + bcrypt.compare against the stored hash, and returns a generic 'Invalid email or password' for both 'no such user' and 'wrong password' to avoid email enumeration.

To let legitimate users recover accounts created by the bug, add a /claim endpoint and page that only succeeds when passwordHash is null, and add scripts/audit-passwordless-users.ts to identify and (with --delete) remove orphan rows that have no reports.

…counts

The /api/auth/login route was upserting users by email and issuing a
session without ever checking the supplied password. Two problems:

  1. Anyone who knew an email could sign in as that user.
  2. Every email ever typed into the form became a real User row,
     with passwordHash = NULL.

Login now does a findUnique + bcrypt.compare against the stored hash,
and returns a generic 'Invalid email or password' for both 'no such
user' and 'wrong password' to avoid email enumeration.

To let legitimate users recover accounts created by the bug, add a
/claim endpoint and page that only succeeds when passwordHash is null,
and add scripts/audit-passwordless-users.ts to identify and (with
--delete) remove orphan rows that have no reports.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nexa Error Error May 22, 2026 4:38pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant