You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
46 lines
1.4 KiB
2 years ago
|
/* TODO - You need to add a mailer integration in `integrations/` and import here.
|
||
|
*
|
||
|
* The integration file can be very simple. Instantiate the email client
|
||
|
* and then export it. That way you can import here and anywhere else
|
||
|
* and use it straight away.
|
||
|
*/
|
||
|
|
||
|
type ResetPasswordMailer = {
|
||
|
to: string
|
||
|
token: string
|
||
|
}
|
||
|
|
||
|
export function forgotPasswordMailer({ to, token }: ResetPasswordMailer) {
|
||
|
// In production, set APP_ORIGIN to your production server origin
|
||
|
const origin = process.env.APP_ORIGIN || process.env.BLITZ_DEV_SERVER_ORIGIN
|
||
|
const resetUrl = `${origin}/auth/reset-password?token=${token}`
|
||
|
|
||
|
const msg = {
|
||
|
from: "TODO@example.com",
|
||
|
to,
|
||
|
subject: "Your Password Reset Instructions",
|
||
|
html: `
|
||
|
<h1>Reset Your Password</h1>
|
||
|
<h3>NOTE: You must set up a production email integration in mailers/forgotPasswordMailer.ts</h3>
|
||
|
|
||
|
<a href="${resetUrl}">
|
||
|
Click here to set a new password
|
||
|
</a>
|
||
|
`,
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
async send() {
|
||
|
if (process.env.NODE_ENV === "production") {
|
||
|
// TODO - send the production email, like this:
|
||
|
// await postmark.sendEmail(msg)
|
||
|
throw new Error("No production email implementation in mailers/forgotPasswordMailer")
|
||
|
} else {
|
||
|
// Preview email in the browser
|
||
|
const previewEmail = (await import("preview-email")).default
|
||
|
await previewEmail(msg)
|
||
|
}
|
||
|
},
|
||
|
}
|
||
|
}
|