Email OTP not working #1340

Closed
opened 2026-03-13 08:33:55 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @Micnubinub on GitHub (Jun 11, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Signin via email
  2. Send emailOTP type signin

Current vs. Expected behavior

OTP should be equal to the saved value

What version of Better Auth are you using?

1.2.9

Provide environment information

MacOS 15.5

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

N/A

Additional context

My email OTP seems not to be working and looking at your code base I think I can see why. I think there separator is different:
In the generate OTP there is:

// packages › better-auth › src › plugins › email-otp › TS index.ts ›  emailOTP › endpoints › sendVerificationOTP > createAuthEndpoint
await ctx.context.internalAdapter
	.createVerificationValue({
		value: `${otp}:0`,
		identifier: `${ctx.body.type}-otp-${email}`,
		expiresAt: getDate(opts.expiresIn, "sec"),
	},
	ctx,
)

In the verifyOTP:

// packages › better-auth › src › plugins › two-factor › otp › TS index.ts › otp2fa › verifyOTP › createAuthEndpoint
const [otp, counter] = toCheckOtp?.value?.split("!") ?? [];
Originally created by @Micnubinub on GitHub (Jun 11, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Signin via email 2. Send emailOTP type signin ### Current vs. Expected behavior OTP should be equal to the saved value ### What version of Better Auth are you using? 1.2.9 ### Provide environment information ```bash MacOS 15.5 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript N/A ``` ### Additional context My email OTP seems not to be working and looking at your code base I think I can see why. I think there separator is different: In the generate OTP there is: ```js // packages › better-auth › src › plugins › email-otp › TS index.ts › emailOTP › endpoints › sendVerificationOTP > createAuthEndpoint await ctx.context.internalAdapter .createVerificationValue({ value: `${otp}:0`, identifier: `${ctx.body.type}-otp-${email}`, expiresAt: getDate(opts.expiresIn, "sec"), }, ctx, ) ``` In the verifyOTP: ```js // packages › better-auth › src › plugins › two-factor › otp › TS index.ts › otp2fa › verifyOTP › createAuthEndpoint const [otp, counter] = toCheckOtp?.value?.split("!") ?? []; ```
GiteaMirror added the bug label 2026-03-13 08:33:55 -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#1340