You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5 KiB
JavaScript

const db = require('../db')
const sendgrid = require('@sendgrid/mail')
sendgrid.setApiKey(process.env.SENDGRID_KEY)
const email = module.exports = {}
email.sendAccountConfirmation = async user => {
const confirmUrl = await db.user.createLoginLink(user.uuid)
const msg = {
to: user.email,
from: {email: 'registration@email.societyofsocks.us', name: 'Society of Socks'},
templateId: 'd-33407f1dd1b14b7b84dd779511039c95',
dynamic_template_data: {
confirmUrl: confirmUrl
}
};
await sendgrid.send(msg);
}
email.sendPasswordReset = async user => {
const resetURL = await db.user.createPasswordReset(user.uuid)
const msg = {
to: user.email,
from: {email: 'accounts@email.societyofsocks.us', name: 'Society of Socks'},
templateId: 'd-90d751cfc8cd4047be39c994ff9d0f5c',
dynamic_template_data: {
resetPasswordURL: resetURL
}
}
await sendgrid.send(msg)
}
email.sendPasswordChanged = async user => {
const msg = {
to: user.email,
from: {email: 'accounts@email.societyofsocks.us', name: 'Society of Socks'},
templateId: 'd-a619058859e44a8a9cf99d77bed2cd35',
dynamic_template_data: {
emailAddress: user.email
}
}
await sendgrid.send(msg)
}
email.sendNoSuchAccount = async email => {
const msg = {
to: email,
from: {email: 'accounts@email.societyofsocks.us', name: 'Society of Socks'},
templateId: 'd-34bb8b2a94264092a47d1f03999be836',
dynamic_template_data: {
emailAddress: email
}
}
await sendgrid.send(msg)
}