Skip to content

Commit

Permalink
made the password stored in db to hashed
Browse files Browse the repository at this point in the history
  • Loading branch information
harikrishnan-git committed Dec 25, 2024
1 parent a8df507 commit 4c262d5
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions backend/controllers/user.auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,23 @@ 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,
});

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" });
Expand Down

0 comments on commit 4c262d5

Please sign in to comment.