Changeset View
Changeset View
Standalone View
Standalone View
lib/email/templates/password-reset.js
const SimpleTemplate = require("./simple"); | const SimpleTemplate = require("./simple"); | ||||
module.exports = async function PasswordReset(app, { email_address, token }) { | module.exports = async function PasswordReset(app, { email_address, token }) { | ||||
const { | const { | ||||
items: [user], | items: [user], | ||||
} = await app.run_action( | } = await app.run_action( | ||||
new app.Sealious.SuperContext(), | new app.Sealious.SuperContext(), | ||||
["collections", "users"], | ["collections", "users"], | ||||
"show", | "show", | ||||
{ filter: { email: email_address } } | { filter: { email: email_address } } | ||||
); | ); | ||||
return SimpleTemplate(app, { | return SimpleTemplate(app, { | ||||
subject: app.i18n("password_reset_email_subject", app.manifest.name), | subject: app.i18n("password_reset_email_subject", app.manifest.name), | ||||
to: `${user.body.username}<${email_address}>`, | to: `${user.username}<${email_address}>`, | ||||
text: ` | text: ` | ||||
${app.i18n("password_reset_email_text", [ | ${app.i18n("password_reset_email_text", [ | ||||
app.manifest.name, | app.manifest.name, | ||||
user.body.username, | user.username, | ||||
])}`, | ])}`, | ||||
buttons: [ | buttons: [ | ||||
{ | { | ||||
text: app.i18n("password_reset_cta"), | text: app.i18n("password_reset_cta"), | ||||
href: `${ | href: `${ | ||||
app.manifest.base_url | app.manifest.base_url | ||||
}/confirm-password-reset?token=${token}&email=${email_address}`, | }/confirm-password-reset?token=${token}&email=${email_address}`, | ||||
}, | }, | ||||
], | ], | ||||
}); | }); | ||||
}; | }; |