|
|
@ -160,4 +160,23 @@ module.exports.resetPassword = async (req, res) => {
|
|
|
|
console.error(error);
|
|
|
|
console.error(error);
|
|
|
|
res.status(500).json(false);
|
|
|
|
res.status(500).json(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// update profile controller
|
|
|
|
|
|
|
|
module.exports.updateProfile = async (req, res) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// Get user ID from the JWT token passed in the authorization headers
|
|
|
|
|
|
|
|
const userId = req.user.id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get updated profile information from the request body
|
|
|
|
|
|
|
|
const { firstName, lastName, mobileNo } = req.body;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update the user's profile in the database
|
|
|
|
|
|
|
|
await User.findByIdAndUpdate(userId, { firstName, lastName, mobileNo });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res.status(200).json({ message: 'Profile updated successfully.' });
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error(error);
|
|
|
|
|
|
|
|
res.status(500).json({ error: 'Internal Server Error' });
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|