[GH-ISSUE #2447] How to Prevent Automatic Resending of Verification Email on Login with requireEmailVerification? #17830

Closed
opened 2026-04-15 16:10:21 -05:00 by GiteaMirror · 7 comments
Owner

Originally created by @phantom2152 on GitHub (Apr 26, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2447

I have a question regarding the requireEmailVerification option.

When I set requireEmailVerification: true, the backend correctly returns a 403 response if a non-verified user tries to log in. I handle this on the frontend by showing a verification modal. However, I’ve noticed that BetterAuth also automatically resends the verification email to the user when this happens.

What I want:
I want the verification email to be sent only when the user explicitly requests it (for example, by clicking a "Resend Verification Email" button in the modal), not automatically when they attempt to log in.

Is there a way to disable this automatic resending of the verification email when a non-verified user tries to log in, while still using requireEmailVerification: true? Or do I need to implement custom logic to handle this scenario?

Here’s my current configuration:

export const auth = betterAuth({
  ...
  emailAndPassword: {
    enabled: true,
    requireEmailVerification: true,
  },
  emailVerification: {
    ...
    sendVerificationEmail: async ({ user, url }) => {
      await sendMail(
        user.email,
        "Verify your email address",
        verification_email_html(url)
      );
    },
    
  },
});

And here is my login handler:

  const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
    ...
    await authClient.signIn.email(
      {
        email,
        password,
      },
      {
        onError: (ctx) => {
          setLoading(false);
          if (ctx.error && ctx.error.status === 403) {
            setShowVerificationModal(true);
          } else {
            setError(ctx.error?.message || "Sign in failed.");
          }
        },
        onSuccess: () => {
         ...
        },
        onRequest: () => ...,
      }
    );
  };

Is there a configuration option to prevent the automatic sending of the verification email on login, or do I need to implement custom logic to handle this scenario?

Originally created by @phantom2152 on GitHub (Apr 26, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2447 I have a question regarding the `requireEmailVerification` option. When I set `requireEmailVerification: true`, the backend correctly returns a 403 response if a non-verified user tries to log in. I handle this on the frontend by showing a verification modal. However, I’ve noticed that BetterAuth also automatically resends the verification email to the user when this happens. What I want: I want the verification email to be sent only when the user explicitly requests it (for example, by clicking a "Resend Verification Email" button in the modal), not automatically when they attempt to log in. Is there a way to disable this automatic resending of the verification email when a non-verified user tries to log in, while still using `requireEmailVerification: true`? Or do I need to implement custom logic to handle this scenario? Here’s my current configuration: ```tsx export const auth = betterAuth({ ... emailAndPassword: { enabled: true, requireEmailVerification: true, }, emailVerification: { ... sendVerificationEmail: async ({ user, url }) => { await sendMail( user.email, "Verify your email address", verification_email_html(url) ); }, }, }); ``` And here is my login handler: ```tsx const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => { ... await authClient.signIn.email( { email, password, }, { onError: (ctx) => { setLoading(false); if (ctx.error && ctx.error.status === 403) { setShowVerificationModal(true); } else { setError(ctx.error?.message || "Sign in failed."); } }, onSuccess: () => { ... }, onRequest: () => ..., } ); }; ``` Is there a configuration option to prevent the automatic sending of the verification email on login, or do I need to implement custom logic to handle this scenario?
GiteaMirror added the locked label 2026-04-15 16:10:21 -05:00
Author
Owner

@atresnjo commented on GitHub (May 1, 2025):

also looking for this

<!-- gh-comment-id:2844548820 --> @atresnjo commented on GitHub (May 1, 2025): also looking for this
Author
Owner

@peterjarian commented on GitHub (May 12, 2025):

This would be a good solution. Sending verification emails on each sign in if a user isn't verified seems a bit spammy.

<!-- gh-comment-id:2870407275 --> @peterjarian commented on GitHub (May 12, 2025): This would be a good solution. Sending verification emails on each sign in if a user isn't verified seems a bit spammy.
Author
Owner

@jingerpie commented on GitHub (May 14, 2025):

The email verification system appears to have inconsistent behavior:

When requireEmailVerification is set to true:

The system automatically sends magic link verification emails
This happens regardless of the sendOnSignUp setting
Users can't sign in until they verify their email

OTP verification works differently:

Only triggered manually OR when sendVerificationOnSignUp is enabled
Provides more control over the authentication flow

The concern is that requireEmailVerification should only make verification mandatory without automatically triggering emails, allowing developers to maintain full control over the authentication flow.

<!-- gh-comment-id:2878346320 --> @jingerpie commented on GitHub (May 14, 2025): The email verification system appears to have inconsistent behavior: When requireEmailVerification is set to true: The system automatically sends magic link verification emails This happens regardless of the sendOnSignUp setting Users can't sign in until they verify their email OTP verification works differently: Only triggered manually OR when sendVerificationOnSignUp is enabled Provides more control over the authentication flow The concern is that requireEmailVerification should only make verification mandatory without automatically triggering emails, allowing developers to maintain full control over the authentication flow.
Author
Owner

@jingerpie commented on GitHub (May 14, 2025):

I started a pull request, please kindly review it @Bekacru

https://github.com/better-auth/better-auth/pull/2660

I added a new parameter sendVerificationOnSignIn, this is true by default, so it will not impact the current app that already using requireEmailVerification as true. Sample code:

export const auth = betterAuth({
  emailAndPassword: {
    requireEmailVerification: true,
    sendVerificationOnSignIn: false, // Email verification still required, but emails won't be sent automatically
  },
});
<!-- gh-comment-id:2881678654 --> @jingerpie commented on GitHub (May 14, 2025): I started a pull request, please kindly review it @Bekacru https://github.com/better-auth/better-auth/pull/2660 I added a new parameter sendVerificationOnSignIn, this is true by default, so it will not impact the current app that already using requireEmailVerification as true. Sample code: ``` export const auth = betterAuth({ emailAndPassword: { requireEmailVerification: true, sendVerificationOnSignIn: false, // Email verification still required, but emails won't be sent automatically }, }); ```
Author
Owner

@phantom2152 commented on GitHub (May 15, 2025):

Yes, Thank you I had my plan but got busy with stuff. @Bekacru please review this.

<!-- gh-comment-id:2882998921 --> @phantom2152 commented on GitHub (May 15, 2025): Yes, Thank you I had my plan but got busy with stuff. @Bekacru please review this.
Author
Owner

@nestorzamili commented on GitHub (Jun 11, 2025):

Is there a way to do the same for sign up, like a sendVerificationOnSignUp option?

<!-- gh-comment-id:2964043968 --> @nestorzamili commented on GitHub (Jun 11, 2025): Is there a way to do the same for sign up, like a sendVerificationOnSignUp option?
Author
Owner

@Abhishek21k commented on GitHub (Sep 18, 2025):

where was this updated in doc as i can't see this option

 "better-auth": "^1.3.7"
<!-- gh-comment-id:3307264349 --> @Abhishek21k commented on GitHub (Sep 18, 2025): where was this updated in doc as i can't see this option ``` "better-auth": "^1.3.7" ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#17830