Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Luxshan2000 committed Oct 12, 2023
1 parent a4e4fd0 commit c50db4e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions backend/src/controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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' });
}
};
Expand Down

0 comments on commit c50db4e

Please sign in to comment.