From 1026ea8a90e2f5f636a245da3e6d3fe668f68d26 Mon Sep 17 00:00:00 2001 From: Matthew Esparza <39199348+matthewesp@users.noreply.github.com> Date: Fri, 31 Jan 2020 13:01:06 -0600 Subject: [PATCH] Adjusted the emails character casing in the register post request & login post request to ensure that there won't be duplicated emails in depending the the users' casing choice. --- routes/api/users.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routes/api/users.js b/routes/api/users.js index 7df8beb..fd022da 100644 --- a/routes/api/users.js +++ b/routes/api/users.js @@ -25,13 +25,13 @@ router.post("/register", (req, res) => { return res.status(400).json(errors); } - User.findOne({ email: req.body.email }).then(user => { + User.findOne({ email: req.body.email.toLowerCase() }).then(user => { if (user) { return res.status(400).json({ email: "Email already exists" }); } else { const newUser = new User({ name: req.body.name, - email: req.body.email, + email: req.body.email.toLowerCase(), password: req.body.password }); @@ -63,7 +63,7 @@ router.post("/login", (req, res) => { return res.status(400).json(errors); } - const email = req.body.email; + const email = req.body.email.toLowerCase(); const password = req.body.password; // Find user by email