fix(auth): persist better-auth 2FA lockout columns - #536
Merged
Conversation
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
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
better-auth1.6.30's two-factor plugin writesfailedVerificationCount/lockedUntilon every TOTP verify (success resets, failure increments).two_factornever declared those fields..set()instead of erroring, so the adapter emittedupdate "two_factor" set where …and enrolment and sign-in both 500'd on a valid code.0278_two_factor_lockout, and pin them with a schema test that reproduces the empty-SETSQL.Fixes #432
Test plan
schema-two-factor.test.ts— lockout columns exist;update … set { failedVerificationCount: 0, lockedUntil: null }emits both column names and is notset wheremigration-journal-integrity.test.tsdb:migratepost-conditions: every column this build declares exists