diff --git a/api/users.js b/api/users.js index 3a2eb9d..a9d09b8 100644 --- a/api/users.js +++ b/api/users.js @@ -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 diff --git a/utils/email.js b/utils/email.js index 6dab7d6..ef308ed 100644 --- a/utils/email.js +++ b/utils/email.js @@ -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) } \ No newline at end of file