Resend Email Verification not working.

When user signup on the system using email and password then after successful sign up sendVerificationEmail is send which is good. But when the user sign in without verifying the email then on UI side it send the email not verified which is also good. However, as per the documentation it says that
If you enable require email verification, users must verify their email before they can log in. And every time a user tries to sign in, sendVerificationEmail is called.
If you enable require email verification, users must verify their email before they can log in. And every time a user tries to sign in, sendVerificationEmail is called.
but it does not trigger the sendVerificationEmail hook due to which link is not send, even after login is done without email verified properly.
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
sendResetPassword: async ({ user, url }) => {
await sendEmail({
user,
url,
subject: "Reset your password",
buttonText: "Reset password",
path: "/auth/reset-password",
frontendURI,
resend,
emailFrom,
});
},
},
emailVerification: {
sendVerificationEmail: async ({ user, url }) => {
await sendEmail({
user,
url,
subject: "Verify your email address",
buttonText: "Verify Email",
path: "",
frontendURI,
resend,
emailFrom,
});
},
autoSignInAfterVerification: true,
sendOnSignUp: true,
}
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
sendResetPassword: async ({ user, url }) => {
await sendEmail({
user,
url,
subject: "Reset your password",
buttonText: "Reset password",
path: "/auth/reset-password",
frontendURI,
resend,
emailFrom,
});
},
},
emailVerification: {
sendVerificationEmail: async ({ user, url }) => {
await sendEmail({
user,
url,
subject: "Verify your email address",
buttonText: "Verify Email",
path: "",
frontendURI,
resend,
emailFrom,
});
},
autoSignInAfterVerification: true,
sendOnSignUp: true,
}
No description
7 Replies
bipulmgr
bipulmgrOP2mo ago
@admin Please help on this part
The Untraceable
The Untraceable2mo ago
If you want just make email verification required and they cant login without verifying their email
bipulmgr
bipulmgrOP2mo ago
According to the Better Auth documentation, the verification email should be automatically resent on every login if the email is not verified. However, this behavior is not happening in my current implementation.
The Untraceable
The Untraceable2mo ago
Ah sorry I didnt see your whole message and recognise thats what youre doing already Add a log to the sendEmailVerification to check if its even being called Might also want to check your spam folder What email sending service are you using?
bipulmgr
bipulmgrOP2mo ago
@The Untraceable I have tested this by adding console.log statements before posting the issue on here. When I sign up with email and password, the verification email is sent as expected. However, when I sign in with an unverified email and password, the sendEmailVerification function is not called. The issue is that sendEmailVerification isn’t being triggered during login, even though my implementation matches the correct example shown in the documentation (screenshot above).
NakedNinja
NakedNinja2mo ago
You have to set sendOnSignIn to true for this to work.
bipulmgr
bipulmgrOP2mo ago
Thanks it worked

Did you find this page helpful?