f0df359db4
Password reset uses Payload's built-in forgot/reset-password flow, customized to link to this app instead of the Payload admin. Order confirmation email and the password-reset email's wording both come from a new Payload email-templates collection, editable without a deploy and previewable via Live Preview at /email-preview/[type] (same mechanism as Posts/LegalPages/Testimonials, sample data instead of a real document). Also: order numbers get a random suffix (prevents guessing, motivated by a considered-and-deferred guest order-lookup feature); the discount code field only shows in the cart when a code is actually active (codes now apply via a ?code= link instead of manual entry); and three navigation gaps found while testing — no reachable login link with an empty cart, no logout link anywhere, no way back from profile to order history. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
37 lines
1.8 KiB
TypeScript
37 lines
1.8 KiB
TypeScript
import { transport } from "./mailer";
|
|
|
|
// Fire-and-forget by design — callers should not await this in a way that
|
|
// blocks or fails the actual error response the customer sees. Wrap
|
|
// everything in its own try/catch so a broken mail relay never becomes a
|
|
// second, worse failure on top of the one being reported.
|
|
export function sendCriticalAlert(subject: string, details: Record<string, unknown>): void {
|
|
transport
|
|
.sendMail({
|
|
from: '"einfach produktiv Alerts" <admin@mk360.de>',
|
|
to: "admin@mk360.de",
|
|
subject: `[einfach produktiv] ${subject}`,
|
|
text: JSON.stringify(details, null, 2),
|
|
})
|
|
.catch((err) => {
|
|
console.error("sendCriticalAlert: failed to send alert email", err);
|
|
});
|
|
}
|
|
|
|
// The *initial* verification email (on registration) is sent by Payload
|
|
// itself, via Customers.ts's own afterChange hook — that one fires
|
|
// automatically on create and needs no separate wiring. This one is only
|
|
// for the "erneut senden" resend path (app/api/account/resend-verification/
|
|
// route.ts), which updates the token via the customer's own session
|
|
// (app/lib/customerAuth.ts's resendVerificationEmail) but has no Payload
|
|
// hook to piggyback on for a plain update, so it sends directly instead —
|
|
// same Hostinger transport as the alert above, just a different template.
|
|
export async function sendVerificationEmail(to: string, firstName: string, token: string): Promise<void> {
|
|
const url = `https://einfach-produktiv.mk360.de/api/account/verify-email?token=${token}`;
|
|
await transport.sendMail({
|
|
from: '"einfach produktiv" <admin@mk360.de>',
|
|
to,
|
|
subject: "Bitte bestätige deine E-Mail-Adresse",
|
|
html: `<p>Hallo ${firstName},</p><p>bitte bestätige deine E-Mail-Adresse für dein Konto bei einfach produktiv:</p><p><a href="${url}">${url}</a></p><p>Der Link ist 24 Stunden gültig.</p>`,
|
|
});
|
|
}
|