[GH-ISSUE #1568] Email OTP Plugin: Option to Accept Multiple OTPs #8824

Closed
opened 2026-04-13 04:02:29 -05:00 by GiteaMirror · 8 comments
Owner

Originally created by @maoosi on GitHub (Feb 25, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1568

Originally assigned to: @bytaesu on GitHub.

Is this suited for github?

  • Yes, this is suited for github

One common customer flow is: The app sends an email OTP to the user. If there's a delay receiving the email, the user might request another code. When both OTP emails eventually arrive, the user may try using the code from the first email, which better-auth will reject.

No matter how reliable the email provider is, I’ve seen this happen repeatedly in real-world apps. In fact, I’ve been asked twice by clients to build custom auth systems to have better control on things like this, which has been their top support request from non-tech-savvy users.

In that context, it would be nice for Better Auth to support a new option to solve this issue.

Describe the solution you'd like

Add an option like allowMultipleOTPs to let all OTPs sent within the expiry period be valid.

emailOTP({
  allowMultipleOTPs: true,
  // other options...
})

Also, after a successful login, all outstanding OTPs should be deleted to prevent any reuse.

Describe alternatives you've considered

Building a custom auth implementation.

Additional context

This would dramatically improve the end user login experience. I don’t think there are official guidelines against having multiple valid OTPs at the same time. The key is ensuring all OTPs have an expiry in place and are properly deleted on a successful login.

Originally created by @maoosi on GitHub (Feb 25, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1568 Originally assigned to: @bytaesu on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. One common customer flow is: The app sends an email OTP to the user. If there's a delay receiving the email, the user might request another code. When both OTP emails eventually arrive, the user may try using the code from the first email, which better-auth will reject. No matter how reliable the email provider is, I’ve seen this happen repeatedly in real-world apps. In fact, I’ve been asked twice by clients to build custom auth systems to have better control on things like this, which has been their top support request from non-tech-savvy users. In that context, it would be nice for Better Auth to support a new option to solve this issue. ### Describe the solution you'd like Add an option like `allowMultipleOTPs` to let all OTPs sent within the expiry period be valid. ```ts emailOTP({ allowMultipleOTPs: true, // other options... }) ``` Also, after a successful login, all outstanding OTPs should be deleted to prevent any reuse. ### Describe alternatives you've considered Building a custom auth implementation. ### Additional context This would dramatically improve the end user login experience. I don’t think there are official guidelines against having multiple valid OTPs at the same time. The key is ensuring all OTPs have an expiry in place and are properly deleted on a successful login.
GiteaMirror added the lockedenhancement labels 2026-04-13 04:02:30 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 2, 2025):

Hi, @maoosi. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested an enhancement for the Email OTP plugin to allow multiple valid OTPs simultaneously within the expiry period.
  • The goal is to handle delayed emails and users entering earlier codes by validating all sent OTPs until expiry.
  • You proposed an allowMultipleOTPs setting that clears outstanding OTPs after a successful login.
  • This feature aims to improve user experience, reduce support requests, and avoid custom authentication workarounds.
  • There has been no further activity or maintainer response on this issue.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of better-auth by commenting here.
  • If I do not hear back within 7 days, I will automatically close this issue.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3146583662 --> @dosubot[bot] commented on GitHub (Aug 2, 2025): Hi, @maoosi. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested an enhancement for the Email OTP plugin to allow multiple valid OTPs simultaneously within the expiry period. - The goal is to handle delayed emails and users entering earlier codes by validating all sent OTPs until expiry. - You proposed an `allowMultipleOTPs` setting that clears outstanding OTPs after a successful login. - This feature aims to improve user experience, reduce support requests, and avoid custom authentication workarounds. - There has been no further activity or maintainer response on this issue. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of better-auth by commenting here. - If I do not hear back within 7 days, I will automatically close this issue. Thank you for your understanding and contribution!
Author
Owner

@maoosi commented on GitHub (Aug 2, 2025):

Yes, still relevant and definitely needed to improve the email OTP flow.

<!-- gh-comment-id:3146733784 --> @maoosi commented on GitHub (Aug 2, 2025): Yes, still relevant and definitely needed to improve the email OTP flow.
Author
Owner

@dosubot[bot] commented on GitHub (Nov 1, 2025):

Hi, @maoosi. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested an enhancement for the Email OTP plugin to allow multiple OTPs to be valid simultaneously during their expiry period.
  • This aims to address problems with delayed emails and earlier codes being rejected.
  • You proposed an allowMultipleOTPs setting that validates all sent OTPs until expiry and clears them after successful login.
  • The feature is intended to improve user experience and reduce support requests.
  • The issue was previously marked as stale due to inactivity, but you confirmed it is still relevant and needed.

Next Steps:

  • Please let me know if this feature request is still relevant to the latest version of better-auth by commenting on this issue.
  • If I do not hear back within 7 days, I will automatically close the issue.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3476534078 --> @dosubot[bot] commented on GitHub (Nov 1, 2025): Hi, @maoosi. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested an enhancement for the Email OTP plugin to allow multiple OTPs to be valid simultaneously during their expiry period. - This aims to address problems with delayed emails and earlier codes being rejected. - You proposed an `allowMultipleOTPs` setting that validates all sent OTPs until expiry and clears them after successful login. - The feature is intended to improve user experience and reduce support requests. - The issue was previously marked as stale due to inactivity, but you confirmed it is still relevant and needed. **Next Steps:** - Please let me know if this feature request is still relevant to the latest version of better-auth by commenting on this issue. - If I do not hear back within 7 days, I will automatically close the issue. Thank you for your understanding and contribution!
Author
Owner

@maoosi commented on GitHub (Nov 8, 2025):

Yes, still relevant and needed!

<!-- gh-comment-id:3506913722 --> @maoosi commented on GitHub (Nov 8, 2025): Yes, still relevant and needed!
Author
Owner

@dosubot[bot] commented on GitHub (Nov 8, 2025):

@Bekacru The user maoosi has confirmed that the issue is still relevant and needs attention despite being closed as stale. Could you please take a look and assist?

<!-- gh-comment-id:3506917397 --> @dosubot[bot] commented on GitHub (Nov 8, 2025): @Bekacru The user maoosi has confirmed that the issue is still relevant and needs attention despite being closed as stale. Could you please take a look and assist?
Author
Owner

@rmarscher commented on GitHub (Nov 13, 2025):

The Magic Link plugin could also benefit from this. Another solution would be to resend/reuse an active verification if it finds one rather than generating a new verification every time.

I would also like the option to not delete a used verification until the expiration. If I click a link that enters the verification in the wrong browser, I have to start over again which is annoying. It would be nice to paste that link into the correct browser and still get signed in. deleteAfterUse: false or something like that.

edit: found related magic link issue https://github.com/better-auth/better-auth/issues/5550

<!-- gh-comment-id:3528875401 --> @rmarscher commented on GitHub (Nov 13, 2025): The Magic Link plugin could also benefit from this. Another solution would be to resend/reuse an active verification if it finds one rather than generating a new verification every time. I would also like the option to not delete a used verification until the expiration. If I click a link that enters the verification in the wrong browser, I have to start over again which is annoying. It would be nice to paste that link into the correct browser and still get signed in. `deleteAfterUse: false` or something like that. edit: found related magic link issue https://github.com/better-auth/better-auth/issues/5550
Author
Owner

@bytaesu commented on GitHub (Feb 2, 2026):

Hi, I'm looking into a way to extend unexpired OTPs

<!-- gh-comment-id:3836582910 --> @bytaesu commented on GitHub (Feb 2, 2026): Hi, I'm looking into a way to extend unexpired OTPs
Author
Owner

@github-actions[bot] commented on GitHub (Mar 31, 2026):

This issue has been locked as it was closed more than 7 days ago. If you're experiencing a similar problem or you have additional context, please open a new issue and reference this one.

<!-- gh-comment-id:4165916591 --> @github-actions[bot] commented on GitHub (Mar 31, 2026): This issue has been locked as it was closed more than 7 days ago. If you're experiencing a similar problem or you have additional context, please open a new issue and reference this one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8824