fix: prevent sign-out crash and surface real email-send failures
- NextAuth session/jwt callbacks no longer return null (the client useSession() hook chokes on a null session, crashing the app on sign-out for deactivated/refreshed sessions) — fixes #57 - UserMenu/Header sign-out handlers close the Manage Users overlay and popover before calling signOut(), and no longer let a rejected signOut() promise go unhandled - Added an app-level error boundary as a safety net for any remaining client render errors - Registration and forgot-password flows now tell the user honestly when the confirmation/reset email failed to send instead of always claiming success — related to #56 - lib/email.ts throws a clear, actionable error when neither SMTP nor Resend is configured, instead of a cryptic SDK error - Documented required SMTP/Resend env vars in DEPLOYMENT_CHECKLIST.md (were missing entirely, which is why no confirmation/reset emails were ever sent in deployed environments) — fixes #56
This commit is contained in:
@@ -73,6 +73,13 @@ async function sendViaSmtp(payload: EmailPayload): Promise<void> {
|
||||
}
|
||||
|
||||
async function sendViaResend(payload: EmailPayload): Promise<void> {
|
||||
if (!process.env.RESEND_API_KEY) {
|
||||
throw new Error(
|
||||
'Missing Resend configuration (RESEND_API_KEY). Set SMTP_HOST/SMTP_USER/SMTP_PASS ' +
|
||||
'or RESEND_API_KEY so password reset / email verification can actually send mail.'
|
||||
);
|
||||
}
|
||||
|
||||
const fromEmail = process.env.RESEND_FROM_EMAIL || process.env.SMTP_FROM_EMAIL || 'onboarding@resend.dev';
|
||||
const fromName = process.env.RESEND_FROM_NAME || process.env.SMTP_FROM_NAME;
|
||||
const replyTo = process.env.RESEND_REPLY_TO || process.env.SMTP_REPLY_TO || fromEmail;
|
||||
|
||||
Reference in New Issue
Block a user