[PR #5826] fix(two-factor): improve error message for bad totp code in 2FA setup #14502

Closed
opened 2026-04-13 09:30:32 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5826

State: closed
Merged: Yes


fixes https://github.com/better-auth/better-auth/issues/2631


Summary by cubic

Return the correct error code for invalid TOTP during 2FA setup. Adds tests to verify missing two-factor cookie and invalid code behaviors.

  • Bug Fixes

    • Invalid TOTP now returns TWO_FACTOR_ERROR_CODES.INVALID_CODE.
    • Missing two-factor cookie returns INVALID_TWO_FACTOR_COOKIE and does not create a session.
  • Refactors

    • Centralized error handling via an invalid() helper for consistent UNAUTHORIZED responses.

Written for commit 0435b401fd. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5826 **State:** closed **Merged:** Yes --- fixes https://github.com/better-auth/better-auth/issues/2631 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Return the correct error code for invalid TOTP during 2FA setup. Adds tests to verify missing two-factor cookie and invalid code behaviors. - **Bug Fixes** - Invalid TOTP now returns TWO_FACTOR_ERROR_CODES.INVALID_CODE. - Missing two-factor cookie returns INVALID_TWO_FACTOR_COOKIE and does not create a session. - **Refactors** - Centralized error handling via an invalid() helper for consistent UNAUTHORIZED responses. <sup>Written for commit 0435b401fdfe97434ce705770fb087f66eb43f37. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:30:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14502