Newer
Older
const config = require('config')
const { Email, services } = require('pubsweet-component-helper-service')
const { getEmailCopy } = require('./emailCopy')
const forgotPath = config.get('forgot-password.url')
const { name: journalName, staffEmail } = config.get('journal')
const unsubscribeSlug = config.get('unsubscribe.url')
module.exports = {
async sendNotifications({ user, baseUrl }) {
const email = new Email({
fromEmail: `${journalName} <${staffEmail}>`,
content: {
ctaLink: services.createUrl(baseUrl, forgotPath, {
email: user.email,
}),
ctaText: 'RESET PASSWORD',
},
})
sendForgotPasswordEmail({ email, baseUrl, user })
},
}
const sendForgotPasswordEmail = ({ email, baseUrl, user }) => {
email.toUser = {
email: user.email,
}
email.content.subject = 'Forgot Password'
email.content.unsubscribeLink = services.createUrl(baseUrl, unsubscribeSlug, {
id: user.id,
})
Sebastian Mihalache
committed
const { html, text } = email.getNotificationBody({
emailBodyProps: getEmailCopy({
emailType: 'user-forgot-password',
}),
})
email.sendEmail({ html, text })
}