Skip to content

Commit

Permalink
Merge pull request #42 from MoaidHashem3/moaid
Browse files Browse the repository at this point in the history
-Fixing Bugs
  • Loading branch information
MoaidHashem3 authored Oct 15, 2024
2 parents 1669167 + 65859c1 commit d7dbc5a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions controllers/handelUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,17 @@ const updateOne = async (req, res) => {
const { id } = req.params;
const { newPassword, ...newUpdate } = req.body; // Extract other fields from req.body
const updateData = { ...newUpdate };

console.log(req.body)
// Handle password hashing if provided
if (newPassword) {
const hashedPassword = await bcrypt.hash(newPassword, 10);
updateData.password = hashedPassword;
}

// If an image is provided, handle file upload
if (req.file) {
updateData.image = req.file.path; // Set image path from multer file upload
}

// Find the user and update
const updatedUser = await usermodel.findByIdAndUpdate(id, updateData, { new: true });

if (!updatedUser) {
Expand Down

0 comments on commit d7dbc5a

Please sign in to comment.