[GH-ISSUE #1014] OTP verification code of type:forget-password sends out email despite account not existing #25871

Closed
opened 2026-04-17 16:10:52 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @PawelPotempa on GitHub (Dec 24, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1014

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Send out OTP verification code of type forget-password.
  2. It sends out the email

Current vs. Expected behavior

I believe it should let the user know the email has been sent out as it does (to keep the existence of the account for that email private), but the backend should not attempt to send out an email if the account doesn't exist, nor create an entry in the verification table.

What version of Better Auth are you using?

1.1.3

Provide environment information

macOS Sonoma 14.5

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

Backend

Auth config (if applicable)

export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: 'pg',
  }),
  plugins: [
    emailOTP({
      async sendVerificationOTP({ email, otp, type }) {
        if (type === 'email-verification') {
          console.log('Sending verification email to', email, 'OTP:', otp);
          await sendVerificationEmail(email, otp);
        } else if (type === 'forget-password') {
          console.log('Sending forget password email to', email, 'OTP:', otp);
          await sendPasswordResetEmail(email, otp);
        }
      },
      disableSignUp: true,
      sendVerificationOnSignUp: true,
    }),
  ],
  emailAndPassword: {
    enabled: true,
    minPasswordLength: 8,
    requireEmailVerification: true,
    sendEmailVerificationOnSignUp: true,
    sendResetPasswordEmail: true,
    autoSignIn: true,
  },
  emailVerification: {
    autoSignInAfterVerification: true,
  },
  socialProviders: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID || '',
      clientSecret: process.env.GOOGLE_CLIENT_SECRET || '',
      scope: ['openid', 'profile', 'email'],
    },
  },
  account: {
    accountLinking: {
      enabled: true,
      requireEmailVerification: true,
      trustedProviders: ['google'],
    },
  },
  rateLimit: {
    window: 60,
    max: 10,
  },
});

Additional context

No response

Originally created by @PawelPotempa on GitHub (Dec 24, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1014 ### Is this suited for github? - [X] Yes, this is suited for github ### To Reproduce 1. Send out OTP verification code of type forget-password. 2. It sends out the email ### Current vs. Expected behavior I believe it should let the user know the email has been sent out as it does (to keep the existence of the account for that email private), but the backend should not attempt to send out an email if the account doesn't exist, nor create an entry in the verification table. ### What version of Better Auth are you using? 1.1.3 ### Provide environment information ```bash macOS Sonoma 14.5 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript export const auth = betterAuth({ database: drizzleAdapter(db, { provider: 'pg', }), plugins: [ emailOTP({ async sendVerificationOTP({ email, otp, type }) { if (type === 'email-verification') { console.log('Sending verification email to', email, 'OTP:', otp); await sendVerificationEmail(email, otp); } else if (type === 'forget-password') { console.log('Sending forget password email to', email, 'OTP:', otp); await sendPasswordResetEmail(email, otp); } }, disableSignUp: true, sendVerificationOnSignUp: true, }), ], emailAndPassword: { enabled: true, minPasswordLength: 8, requireEmailVerification: true, sendEmailVerificationOnSignUp: true, sendResetPasswordEmail: true, autoSignIn: true, }, emailVerification: { autoSignInAfterVerification: true, }, socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID || '', clientSecret: process.env.GOOGLE_CLIENT_SECRET || '', scope: ['openid', 'profile', 'email'], }, }, account: { accountLinking: { enabled: true, requireEmailVerification: true, trustedProviders: ['google'], }, }, rateLimit: { window: 60, max: 10, }, }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-17 16:10: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#25871