From 3f4f0cd8287f3c79e7b58f8bedfd03031327c141 Mon Sep 17 00:00:00 2001 From: Ashelyn Dawn Date: Mon, 25 Jan 2021 19:39:01 -0700 Subject: [PATCH] Handles password reset where no user found --- api/users.js | 5 +++-- utils/email.js | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) 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