Skip to content

fix(auth): persist better-auth 2FA lockout columns - #536

Merged
mortondev merged 1 commit into
mainfrom
fix/two-factor-lockout-columns
Sep 10, 2026
Merged

fix(auth): persist better-auth 2FA lockout columns#536
mortondev merged 1 commit into
mainfrom
fix/two-factor-lockout-columns

Conversation

@mortondev

Copy link
Copy Markdown
Member

Summary

  • better-auth 1.6.30's two-factor plugin writes failedVerificationCount / lockedUntil on every TOTP verify (success resets, failure increments). two_factor never declared those fields.
  • Drizzle drops unknown keys from .set() instead of erroring, so the adapter emitted update "two_factor" set where … and enrolment and sign-in both 500'd on a valid code.
  • Add the columns in the Drizzle table and migration 0278_two_factor_lockout, and pin them with a schema test that reproduces the empty-SET SQL.

Fixes #432

Test plan

  • schema-two-factor.test.ts — lockout columns exist; update … set { failedVerificationCount: 0, lockedUntil: null } emits both column names and is not set where
  • migration-journal-integrity.test.ts
  • db:migrate post-conditions: every column this build declares exists
  • After merge: enable 2FA on a workspace, complete TOTP enrolment, sign out, sign in with a valid code

better-auth 1.6.30 writes failed_verification_count and locked_until
on every TOTP verify. The two_factor table never declared them, so
Drizzle emitted `update "two_factor" set  where …` and enrolment /
sign-in 500'd. Add the columns and pin them in a schema test.

Fixes #432
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@mortondev
mortondev merged commit bcd4e6b into main Sep 10, 2026
11 of 13 checks passed
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.

2FA sign-in fails: better-auth 1.6.30 lockout writes columns two_factor doesn't declare

1 participant