[PR #4723] [MERGED] feat(email-otp): allow returning undefined in generateOTP #5547

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4723
Author: @ping-maxwell
Created: 9/17/2025
Status: Merged
Merged: 9/17/2025
Merged by: @himself65

Base: canaryHead: chore/email-otp-generator-return-undefine


📝 Commits (1)

  • 9c3f5d1 chore(email-otp): Allow returning undefined in generateOTP

📊 Changes

1 file changed (+16 additions, -15 deletions)

View changed files

📝 packages/better-auth/src/plugins/email-otp/index.ts (+16 -15)

📄 Description

Right now you're forced to return an OTP value in the generateOTP function as part of the email-otp plugin. In some cases you may just want to return an OTP under a specific case, and just have nothing else returned to default to the default OTP generator.


Summary by cubic

Let generateOTP in the email-otp plugin return undefined and fall back to the default numeric generator. This lets you only override OTPs for specific cases.

  • New Features
    • generateOTP can now return string | undefined.
    • Added a defaultOTPGenerator and a safe fallback when generateOTP returns undefined.

🔄 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/4723 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 9/17/2025 **Status:** ✅ Merged **Merged:** 9/17/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `chore/email-otp-generator-return-undefine` --- ### 📝 Commits (1) - [`9c3f5d1`](https://github.com/better-auth/better-auth/commit/9c3f5d1c4e8534d1f3407d384449cb6463545d0a) chore(email-otp): Allow returning undefined in `generateOTP` ### 📊 Changes **1 file changed** (+16 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/email-otp/index.ts` (+16 -15) </details> ### 📄 Description Right now you're forced to return an OTP value in the `generateOTP` function as part of the email-otp plugin. In some cases you may just want to return an OTP under a specific case, and just have nothing else returned to default to the default OTP generator. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Let generateOTP in the email-otp plugin return undefined and fall back to the default numeric generator. This lets you only override OTPs for specific cases. - **New Features** - generateOTP can now return string | undefined. - Added a defaultOTPGenerator and a safe fallback when generateOTP returns undefined. <!-- 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:26:52 -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#5547