/* * To be used in the `sendVerificationRequest` function of the `email` provider of NextAuth.js. */ import * as React from "react"; import { Body, Container, Head, Heading, Html, Img, Preview, Section, Tailwind, Text, } from "@react-email/components"; import { createTransport } from "nodemailer"; import { render } from "@react-email/render"; import { type SendVerificationRequestParams } from "next-auth/providers/email"; interface ResetPasswordTemplateProps { token: string; } const ResetPasswordTemplate = ({ token }: ResetPasswordTemplateProps) => { const previewText = "Your Langfuse reset code"; return ( {previewText}
Langfuse
Forgot your Langfuse password?
It happens to the best of us.
Your one time passcode: {token}
This code is valid for 3 minutes. If you did not request a reset, you can ignore this email.
); }; export async function sendResetPasswordVerificationRequest( params: SendVerificationRequestParams, ) { const { identifier, token, provider } = params as SendVerificationRequestParams & { token: string }; const transport = createTransport(provider.server); const htmlTemplate = await render(); const result = await transport.sendMail({ to: identifier, from: provider.from, subject: `Your Langfuse password reset code`, text: `Use the following code to reset your Langfuse password: ${token}\n\nThis code will expire in 3 minutes. If you did not request a reset, you can ignore this email.`, html: htmlTemplate, }); const failed = result.rejected.concat(result.pending).filter(Boolean); if (failed.length) { throw new Error(`Email(s) (${failed.join(", ")}) could not be sent`); } } export default ResetPasswordTemplate;