Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const config = require('config')
const forgotPath = config.get('forgot-password.url')
const unsubscribeSlug = config.get('unsubscribe.url')
const { Email, services } = require('pubsweet-component-helper-service')
const { getEmailCopy } = require('./emailCopy')
module.exports = {
async sendNotifications({ user, baseUrl }) {
const email = new Email({
type: 'user',
content: {
ctaLink: services.createUrl(baseUrl, forgotPath, {
email: user.email,
token: user.passwordResetToken,
}),
ctaText: 'RESET PASSWORD',
},
})
sendForgotPasswordEmail({ email, baseUrl, user })
},
}
const sendForgotPasswordEmail = ({ email, baseUrl, user }) => {
email.toUser = {
email: user.email,
name: user.name,
}
email.content.subject = 'Forgot Password'
email.content.unsubscribeLink = services.createUrl(baseUrl, unsubscribeSlug, {
id: user.id,
})
email.content.signatureName = 'Hindawi'
const { html, text } = email.getBody({
body: getEmailCopy({
emailType: 'user-forgot-password',
}),
})
email.sendEmail({ html, text })
}