Prefer Supabase SMTP for verification emails; fallback to server endpoint
cgen-6dc427ca42924f7982520fb28ca57b69
This commit is contained in:
parent
b24add0a88
commit
3aa41f8784
1 changed files with 15 additions and 3 deletions
|
|
@ -83,6 +83,21 @@ export default function Welcome({
|
||||||
setFallbackVerificationLink(null);
|
setFallbackVerificationLink(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// First try Supabase to send via your configured SMTP
|
||||||
|
const { error: resendError } = await supabase.auth.resend({
|
||||||
|
type: "signup",
|
||||||
|
email: emailAddress,
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
if (!resendError) {
|
||||||
|
toastSuccess({
|
||||||
|
title: "Verification email sent",
|
||||||
|
description: `We sent a confirmation message to ${emailAddress}.`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to server-generated link (and optional Resend delivery)
|
||||||
const redirectTo =
|
const redirectTo =
|
||||||
typeof window !== "undefined"
|
typeof window !== "undefined"
|
||||||
? `${window.location.origin}/login?verified=1`
|
? `${window.location.origin}/login?verified=1`
|
||||||
|
|
@ -103,7 +118,6 @@ export default function Welcome({
|
||||||
.catch(() => ({}) as Record<string, any>);
|
.catch(() => ({}) as Record<string, any>);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
// If server returned a manual verification link despite the error, surface it to the user.
|
|
||||||
const manualLink =
|
const manualLink =
|
||||||
typeof payload?.verificationUrl === "string"
|
typeof payload?.verificationUrl === "string"
|
||||||
? payload.verificationUrl
|
? payload.verificationUrl
|
||||||
|
|
@ -126,8 +140,6 @@ export default function Welcome({
|
||||||
"Failed to send verification email",
|
"Failed to send verification email",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsSendingVerification(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue