Skip to content

Commit

Permalink
fix security issue sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
pelazas committed Apr 29, 2024
1 parent 869b964 commit 2c95bd8
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions users/userservice/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,21 @@ let UserController = {
res.json(response);
},
getUsersByIds: async (req, res) => {
const userIds = req.body.userIds;
const users = [];
for(const id of userIds){
console.log(id)
const user = await User.findOne({ uuid: id });
users.push(user);
try{
const userIds = req.body.userIds;
const users = [];
for(const id of userIds){
if(!isValidUuidV4(id)){
throw new Error(`Invalid UUID provided`);
}
const user = await User.findOne({ uuid: id });
users.push(user);
}
res.json(users);
} catch(error){
console.log(error)
res.status(500).json({ error: error.message });
}
res.json(users);
},
leaveGroup: async (req, res) => {
const id = req.params.id;
Expand Down

0 comments on commit 2c95bd8

Please sign in to comment.