From 4c262d55c5ad0427dcaf711c86a3893085ab5636 Mon Sep 17 00:00:00 2001 From: harikrishnan-git Date: Wed, 25 Dec 2024 21:02:32 +0530 Subject: [PATCH] made the password stored in db to hashed --- backend/controllers/user.auth.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/backend/controllers/user.auth.js b/backend/controllers/user.auth.js index c803c6d..e762794 100644 --- a/backend/controllers/user.auth.js +++ b/backend/controllers/user.auth.js @@ -19,10 +19,11 @@ export const Signup = async (req, res) => { const boyProfile = `https://avatar.iran.liara.run/public/boy?username=${userName}`; const girlProfile = `https://avatar.iran.liara.run/public/girl?username=${userName}`; + const hash_password = await bcrypt.hash(password, 10); const newUser = await new User({ fullName, userName, - password, + password: hash_password, gender, profilePic: gender === "male" ? boyProfile : girlProfile, }); @@ -30,17 +31,11 @@ export const Signup = async (req, res) => { newUser .save() .then((result) => { - res.status(201).json({ - _id: newUser._id, - fullName: newUser.fullName, - userName: newUser.userName, - gender: newUser.gender, - }); + res.redirect("/auth/login"); }) .catch((err) => { console.log(err); }); - res.redirect("/auth/login"); } catch (err) { console.log(err.message); res.status(500).send({ error: "Internal server error" });