[PR #5739] [CLOSED] Added Two-Factor option to skip TOTP code creation #31791

Closed
opened 2026-04-17 22:40:12 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5739
Author: @jackh-sh
Created: 11/3/2025
Status: Closed

Base: mainHead: canary


📝 Commits (3)

  • a4f4f0e Added an option just to enable otp when enabling two-factor authentication
  • cf41761 Added a test to make sure we skip totp when otp method is selected
  • a5601c3 Added a docs page to show option

📊 Changes

3 files changed (+66 additions, -14 deletions)

View changed files

📝 docs/content/docs/plugins/2fa.mdx (+5 -1)
📝 packages/better-auth/src/plugins/two-factor/index.ts (+38 -13)
📝 packages/better-auth/src/plugins/two-factor/two-factor.test.ts (+23 -0)

📄 Description

I added an option to the API to skip TOTP creation so that you can enable two factor auth for the OTP method.


Summary by cubic

Add a new twoFactorMethod option to enable 2FA using OTP without generating TOTP codes or QR data. Default remains TOTP, so existing integrations keep working.

  • New Features
    • API: twoFactor.enable accepts twoFactorMethod: "otp" | "totp" (default "totp").
    • "otp" skips TOTP setup and verification-on-enable, marks the user 2FA-enabled, and returns { twoFactor: true }.
    • "totp" continues to return totpURI and backupCodes as before.
    • Docs updated to show the new parameter.
    • Test added for the OTP path to ensure no TOTP artifacts are created.

Written for commit a5601c39d5. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5739 **Author:** [@jackh-sh](https://github.com/jackh-sh) **Created:** 11/3/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `canary` --- ### 📝 Commits (3) - [`a4f4f0e`](https://github.com/better-auth/better-auth/commit/a4f4f0edb5db69aeb04991a4efeef83f99bf9daa) Added an option just to enable otp when enabling two-factor authentication - [`cf41761`](https://github.com/better-auth/better-auth/commit/cf41761c295de3589239d44eadd6c571c01716b2) Added a test to make sure we skip totp when otp method is selected - [`a5601c3`](https://github.com/better-auth/better-auth/commit/a5601c39d583b366bc3cd90cd1e64c995fc2d160) Added a docs page to show option ### 📊 Changes **3 files changed** (+66 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/2fa.mdx` (+5 -1) 📝 `packages/better-auth/src/plugins/two-factor/index.ts` (+38 -13) 📝 `packages/better-auth/src/plugins/two-factor/two-factor.test.ts` (+23 -0) </details> ### 📄 Description I added an option to the API to skip TOTP creation so that you can enable two factor auth for the OTP method. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add a new twoFactorMethod option to enable 2FA using OTP without generating TOTP codes or QR data. Default remains TOTP, so existing integrations keep working. - **New Features** - API: twoFactor.enable accepts twoFactorMethod: "otp" | "totp" (default "totp"). - "otp" skips TOTP setup and verification-on-enable, marks the user 2FA-enabled, and returns { twoFactor: true }. - "totp" continues to return totpURI and backupCodes as before. - Docs updated to show the new parameter. - Test added for the OTP path to ensure no TOTP artifacts are created. <sup>Written for commit a5601c39d583b366bc3cd90cd1e64c995fc2d160. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 22:40:12 -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#31791