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.
35 lines
918 B
JavaScript
35 lines
918 B
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)
|
|
} |