Resend Verification Email
I'm trying to resend the email verification when a user tries to sign-in and has not yet verified their email..
I'm getting the correct error code but the email never gets sent...
async function onSubmit(values: z.infer<typeof signInFormSchema>) {
const { email, password } = values;
await authClient.signIn.email(
{ email, password, callbackURL: "/dashboard"} ,
{
onRequest: () => {},
onSuccess: () => {},
onError: async (ctx) => {
if (ctx.error.status === 403) {
setError("Check inbox, verify email");
console.log("sending email to ...", email);
// resend the verification email
try {
await authClient.sendVerificationEmail({
email,
callbackURL: "/dashboard",
});
toast({title: "Verification email sent"});
async function onSubmit(values: z.infer<typeof signInFormSchema>) {
const { email, password } = values;
await authClient.signIn.email(
{ email, password, callbackURL: "/dashboard"} ,
{
onRequest: () => {},
onSuccess: () => {},
onError: async (ctx) => {
if (ctx.error.status === 403) {
setError("Check inbox, verify email");
console.log("sending email to ...", email);
// resend the verification email
try {
await authClient.sendVerificationEmail({
email,
callbackURL: "/dashboard",
});
toast({title: "Verification email sent"});
POST /api/auth/sign-in/email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 403 in 5016ms
POST /api/auth/send-verification-email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 200 in 275ms
POST /api/auth/sign-in/email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 403 in 5016ms
POST /api/auth/send-verification-email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 200 in 275ms
1 Reply
emailVerification: {
sendOnSignUp: true,
autoSignInAfterVerification: true,
sendVerificationEmail: async ({ user, url }) => {
console.log("sendVerificaitonEmail being called", user, url);
try {
await resend.emails.send({
from: "ATS <[email protected]",
to: user.email,
subject: "Email Verification",
react: VerificationEmail({
name: user.name || "User",
verificationLink: url,
}),
});
} catch (error) {
console.error("Error sending verification email:", error);
throw error;
}
},
},
emailVerification: {
sendOnSignUp: true,
autoSignInAfterVerification: true,
sendVerificationEmail: async ({ user, url }) => {
console.log("sendVerificaitonEmail being called", user, url);
try {
await resend.emails.send({
from: "ATS <[email protected]",
to: user.email,
subject: "Email Verification",
react: VerificationEmail({
name: user.name || "User",
verificationLink: url,
}),
});
} catch (error) {
console.error("Error sending verification email:", error);
throw error;
}
},
},
sendVerificationEmail
is being triggered
sendVerificaitonEmail being called {
id: 'UjmfxjTzc5ilfeheTQhfDQ0Ah6HlXgGb',
name: 'Yup',
email: '[email protected]',
emailVerified: false,
image: null,
createdAt: 2025-01-22T17:51:29.620Z,
updatedAt: 2025-01-22T17:51:29.620Z,
role: 'admin',
banned: null,
banReason: null,
banExpires: null
} http://localhost:3000/api/auth/verify-email?token=12345&callbackURL=/dashboard
POST /api/auth/sign-in/email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 403 in 3960ms
sendVerificaitonEmail being called {
id: 'UjmfxjTzc5ilfeheTQhfDQ0Ah6HlXgGb',
name: 'Yup',
email: '[email protected]',
emailVerified: false,
image: null,
createdAt: 2025-01-22T17:51:29.620Z,
updatedAt: 2025-01-22T17:51:29.620Z,
role: 'admin',
banned: null,
banReason: null,
banExpires: null
} http://localhost:3000/api/auth/verify-email?token=12345&callbackURL=/dashboard
POST /api/auth/send-verification-email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 200 in 239ms
sendVerificaitonEmail being called {
id: 'UjmfxjTzc5ilfeheTQhfDQ0Ah6HlXgGb',
name: 'Yup',
email: '[email protected]',
emailVerified: false,
image: null,
createdAt: 2025-01-22T17:51:29.620Z,
updatedAt: 2025-01-22T17:51:29.620Z,
role: 'admin',
banned: null,
banReason: null,
banExpires: null
} http://localhost:3000/api/auth/verify-email?token=12345&callbackURL=/dashboard
POST /api/auth/sign-in/email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 403 in 3960ms
sendVerificaitonEmail being called {
id: 'UjmfxjTzc5ilfeheTQhfDQ0Ah6HlXgGb',
name: 'Yup',
email: '[email protected]',
emailVerified: false,
image: null,
createdAt: 2025-01-22T17:51:29.620Z,
updatedAt: 2025-01-22T17:51:29.620Z,
role: 'admin',
banned: null,
banReason: null,
banExpires: null
} http://localhost:3000/api/auth/verify-email?token=12345&callbackURL=/dashboard
POST /api/auth/send-verification-email?currentURL=http%3A%2F%2Flocalhost%3A3001%2Fsign-in 200 in 239ms
http://localhost:3000/api/auth/verify-email?
..
oh wow I was running an outdate .env.local
yikes
Still not triggering the resend email though