Skip to content

Commit

Permalink
Returned all the users after updating a user
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliviier-dev committed Mar 17, 2024
1 parent 8e53ad8 commit ac52a3a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/controllers/authController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ module.exports.updateUserRole = async(req: Request, res: Response) => {
const userNewRole = (user.role === 'admin') ? 'user' : 'admin';

await User.findByIdAndUpdate(userId, { role: userNewRole });
const users = await User.find({}, '-password');

res.status(200).json({ message: "User role updated successfully" });
res.status(200).json({ message: "User role updated successfully", users });
} catch (error) {
console.error("Error updating user role:", error);
res.status(500).json({ message: "Internal server error" });
Expand Down

0 comments on commit ac52a3a

Please sign in to comment.