Handles password reset where no user found

main
Ashelyn Dawn 4 years ago
parent dded710211
commit 3f4f0cd828

@ -47,13 +47,14 @@ router.post('/recover', parseJSON, validate.validEmail('email'), async (req, res
if(user)
email.sendPasswordReset(user)
else
email.sendNoSuchAccount(req.body.email)
res.end()
})
router.post('/recover/password', parseJSON,
validate.validPassword('password'),
validate.validPassword('password'),
validate.bothPasswordsMatch, async (req, res) => {
const {password, link_uuid, link_key} = req.body

@ -31,5 +31,18 @@ email.sendPasswordReset = async user => {
}
}
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)
}
Loading…
Cancel
Save