[PR #5961] feat(phone-number): support custom otp genration #23249

Open
opened 2026-04-15 21:34:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5961
Author: @franciscohanna92
Created: 11/13/2025
Status: 🔄 Open

Base: mainHead: feat/phone-number-custom-otp-generation


📝 Commits (10+)

  • a2e0f52 feat(phone-number): support custom otp genration
  • 363b021 fix: return literal from custom generateOTP function
  • f8f7804 fix: use opts instead of options
  • 66e6cf5 fix: generate otp based on length
  • b84c932 Merge branch 'canary' into feat/phone-number-custom-otp-generation
  • 9749a90 Merge branch 'canary' into feat/phone-number-custom-otp-generation
  • 7354385 Merge branch 'canary' into feat/phone-number-custom-otp-generation
  • 0dec2b7 Merge branch 'canary' into feat/phone-number-custom-otp-generation
  • a20b716 Merge branch 'canary' into feat/phone-number-custom-otp-generation
  • aefc482 Merge branch 'canary' into feat/phone-number-custom-otp-generation

📊 Changes

3 files changed (+88 additions, -3 deletions)

View changed files

📝 docs/content/docs/plugins/phone-number.mdx (+13 -0)
📝 packages/better-auth/src/plugins/phone-number/index.ts (+17 -3)
📝 packages/better-auth/src/plugins/phone-number/phone-number.test.ts (+58 -0)

📄 Description

closes #4702

based on #1159


Summary by cubic

Adds support for custom OTP generation in the phoneNumber plugin so apps can control OTP format. Falls back to the default generator when not provided.

  • New Features
    • Added generateOTP option (sync/async) to PhoneNumberOptions for custom code generation; accepts otpLength and returns a string.
    • Applied in verification during sign-in, sendOtp, and password reset flows.
    • Updated docs with usage example and added tests to verify custom generator behavior.

Written for commit aefc4820cd. 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/5961 **Author:** [@franciscohanna92](https://github.com/franciscohanna92) **Created:** 11/13/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/phone-number-custom-otp-generation` --- ### 📝 Commits (10+) - [`a2e0f52`](https://github.com/better-auth/better-auth/commit/a2e0f524de32b3ec01aeb849e9ef45a0bb6de06b) feat(phone-number): support custom otp genration - [`363b021`](https://github.com/better-auth/better-auth/commit/363b021e575f6524a7b57a5a072d38e1d51876fe) fix: return literal from custom generateOTP function - [`f8f7804`](https://github.com/better-auth/better-auth/commit/f8f78040c0b6aa2f274a82d2cf44dfdf6d12898a) fix: use opts instead of options - [`66e6cf5`](https://github.com/better-auth/better-auth/commit/66e6cf5202822dc20fe968a1b1a890610c3a133c) fix: generate otp based on length - [`b84c932`](https://github.com/better-auth/better-auth/commit/b84c9323145d0f02db2d9a5ed34fe115526dcb82) Merge branch 'canary' into feat/phone-number-custom-otp-generation - [`9749a90`](https://github.com/better-auth/better-auth/commit/9749a90a88ee73dcfb642552e9cf8d3aab8d6925) Merge branch 'canary' into feat/phone-number-custom-otp-generation - [`7354385`](https://github.com/better-auth/better-auth/commit/735438573cba73ffa3ac9f9d68becbb57add1a02) Merge branch 'canary' into feat/phone-number-custom-otp-generation - [`0dec2b7`](https://github.com/better-auth/better-auth/commit/0dec2b77229a3a814f73006062ab4d9be586c34d) Merge branch 'canary' into feat/phone-number-custom-otp-generation - [`a20b716`](https://github.com/better-auth/better-auth/commit/a20b716c3fc159bef24014d8f075cd21f14fe1db) Merge branch 'canary' into feat/phone-number-custom-otp-generation - [`aefc482`](https://github.com/better-auth/better-auth/commit/aefc4820cd39f424b8e0b0f693e789676ebb65ce) Merge branch 'canary' into feat/phone-number-custom-otp-generation ### 📊 Changes **3 files changed** (+88 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/phone-number.mdx` (+13 -0) 📝 `packages/better-auth/src/plugins/phone-number/index.ts` (+17 -3) 📝 `packages/better-auth/src/plugins/phone-number/phone-number.test.ts` (+58 -0) </details> ### 📄 Description closes #4702 based on #1159 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds support for custom OTP generation in the phoneNumber plugin so apps can control OTP format. Falls back to the default generator when not provided. - **New Features** - Added generateOTP option (sync/async) to PhoneNumberOptions for custom code generation; accepts otpLength and returns a string. - Applied in verification during sign-in, sendOtp, and password reset flows. - Updated docs with usage example and added tests to verify custom generator behavior. <sup>Written for commit aefc4820cd39f424b8e0b0f693e789676ebb65ce. 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-15 21:34:25 -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#23249