mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
use sendgrid template for confirmation and password-reset email
This commit is contained in:
parent
8d5da15064
commit
82da9e6ede
1 changed files with 16 additions and 6 deletions
|
|
@ -8,14 +8,19 @@ export const sendConfirmationEmail = async (user: {
|
|||
email: string
|
||||
}): Promise<boolean> => {
|
||||
// generate confirmation link
|
||||
const confirmationToken = generateVerificationToken(user.id)
|
||||
const confirmationLink = `${env.client.url}/confirm-email/${confirmationToken}`
|
||||
const token = generateVerificationToken(user.id)
|
||||
const link = `${env.client.url}/confirm-email/${token}`
|
||||
// send email
|
||||
const dynamicTemplateData = {
|
||||
name: user.name,
|
||||
link,
|
||||
}
|
||||
|
||||
return sendEmail({
|
||||
from: env.sender.message,
|
||||
to: user.email,
|
||||
subject: 'Confirm your email',
|
||||
text: `Hey ${user.name},\n\nPlease confirm your email by clicking the link below:\n\n${confirmationLink}\n\n`,
|
||||
templateId: env.sendgrid.confirmationTemplateId,
|
||||
dynamicTemplateData,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -28,10 +33,15 @@ export const sendPasswordResetEmail = async (user: {
|
|||
const token = generateVerificationToken(user.id)
|
||||
const link = `${env.client.url}/reset-password/${token}`
|
||||
// send email
|
||||
const dynamicTemplateData = {
|
||||
name: user.name,
|
||||
link,
|
||||
}
|
||||
|
||||
return sendEmail({
|
||||
from: env.sender.message,
|
||||
to: user.email,
|
||||
subject: 'Reset your password',
|
||||
text: `Hey ${user.name},\n\nPlease reset your password by clicking the link below:\n\n${link}\n\n`,
|
||||
templateId: env.sendgrid.resetPasswordTemplateId,
|
||||
dynamicTemplateData,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue