[PR #5259] [CLOSED] feat(phone): add customOTP option #5885

Closed
opened 2026-03-13 12:40:10 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5259
Author: @Manokii
Created: 10/12/2025
Status: Closed

Base: canaryHead: phone-custom-otp


📝 Commits (5)

  • 538a382 feat(phone): add customOTP option
  • 98500a1 fix(phone): fix skipSendOtp check
  • 26ba952 fix(phone): fix typo
  • 7b6bfa0 Merge branch 'canary' into phone-custom-otp
  • 0ab270b chore(phone): split usage examples for customOTP

📊 Changes

3 files changed (+188 additions, -9 deletions)

View changed files

📝 docs/content/docs/plugins/phone-number.mdx (+44 -0)
📝 packages/better-auth/src/plugins/phone-number/index.ts (+45 -8)
📝 packages/better-auth/src/plugins/phone-number/phone-number.test.ts (+99 -1)

📄 Description

Feature

Custom OTP for testing/bypass purposes

Why

I've tried to implement a custom otp for specific phoneNumbers in sendOTP() but the problem was if I create a new row in verification table, the original verification code generated before sendOTP() is called won't get deleted

Changes

  • added a customOTP option to phoneNumber() plugin
  • added test cases for customOTP
  • updated phone-number.mdx with custom otp usage

Question:

  • should this apply to requestPasswordResetPhoneNumber & forgetPasswordPhoneNumber?

Summary by cubic

Adds a customOTP option to the phoneNumber plugin to use predefined OTPs for specific numbers and optionally skip sending SMS. Ensures the stored verification code matches the custom code by generating it before creating the verification record.

  • New Features
    • customOTP.phoneNumbers: record or async function mapping phone numbers to OTP codes.
    • customOTP.skipSendOTP: skips sendOTP when a custom code is used.
    • Added unit tests and updated docs with usage examples.

🔄 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/5259 **Author:** [@Manokii](https://github.com/Manokii) **Created:** 10/12/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `phone-custom-otp` --- ### 📝 Commits (5) - [`538a382`](https://github.com/better-auth/better-auth/commit/538a382428a07e3607810eace42dfb22d1856c70) feat(phone): add `customOTP` option - [`98500a1`](https://github.com/better-auth/better-auth/commit/98500a18c9d4030fce8e0d1f4cc2f65fb6f352af) fix(phone): fix skipSendOtp check - [`26ba952`](https://github.com/better-auth/better-auth/commit/26ba952927b83f686fce6cc686f7f08cb7a134e0) fix(phone): fix typo - [`7b6bfa0`](https://github.com/better-auth/better-auth/commit/7b6bfa053871afe81dc32d68e99098e9609a615b) Merge branch 'canary' into phone-custom-otp - [`0ab270b`](https://github.com/better-auth/better-auth/commit/0ab270ba3a0b66537e008d8bb6886273c6a774db) chore(phone): split usage examples for customOTP ### 📊 Changes **3 files changed** (+188 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/phone-number.mdx` (+44 -0) 📝 `packages/better-auth/src/plugins/phone-number/index.ts` (+45 -8) 📝 `packages/better-auth/src/plugins/phone-number/phone-number.test.ts` (+99 -1) </details> ### 📄 Description ### Feature Custom OTP for testing/bypass purposes ### Why I've tried to implement a custom otp for specific phoneNumbers in `sendOTP()` but the problem was if I create a new row in verification table, the original verification code generated before sendOTP() is called won't get deleted ### Changes - added a `customOTP` option to `phoneNumber()` plugin - added test cases for `customOTP` - updated `phone-number.mdx` with custom otp usage ### Question: - should this apply to `requestPasswordResetPhoneNumber` & `forgetPasswordPhoneNumber`? <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a customOTP option to the phoneNumber plugin to use predefined OTPs for specific numbers and optionally skip sending SMS. Ensures the stored verification code matches the custom code by generating it before creating the verification record. - **New Features** - customOTP.phoneNumbers: record or async function mapping phone numbers to OTP codes. - customOTP.skipSendOTP: skips sendOTP when a custom code is used. - Added unit tests and updated docs with usage examples. <!-- 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-03-13 12:40:10 -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#5885