From c50db4ef3ebd90d85898dc234a77921a847d6aa3 Mon Sep 17 00:00:00 2001 From: Luxshan2000 Date: Thu, 12 Oct 2023 12:18:25 +0530 Subject: [PATCH] review --- backend/src/controllers/authController.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/src/controllers/authController.js b/backend/src/controllers/authController.js index cca4886..49d0932 100644 --- a/backend/src/controllers/authController.js +++ b/backend/src/controllers/authController.js @@ -13,15 +13,24 @@ const signup = async (req, res, isWeb) => { const otp = OTPGenerator() + + const { email, password, name } = req.body; + const isAdmin = false + + + + const saltRounds = 10; // Adjust const hashedPassword = await bcrypt.hash(password, saltRounds); const user = await User.findOne({ email }); - if (!user){ + if (!user){ + + // Create a new user - const user = new User({ email, hashedPassword, name, otp }); + const user = new User({ email, hashedPassword, name, otp, isAdmin }); await user.save(); console.log("Start"); @@ -49,6 +58,7 @@ const signup = async (req, res, isWeb) => { return res.status(404).json({error : "User exists", success : false}) } } catch (error) { + console.log(error) res.status(500).json({ error: 'Signup failed' }); } };