Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Arquisoft/wiq_es1a into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
iyanfdezz committed Apr 7, 2024
2 parents 4420e46 + 8b6bf08 commit aca33d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions users/userservice/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ app.post("/adduser", async (req, res) => {
// Check if required fields are present in the request body
validateRequiredFields(req, ["username", "password"]);

const username = req.body.username;

// Check if the username already exists
const existingUser = await User.findOne({ username: req.body.username });
const existingUser = await User.findOne({ username: username });

Check failure

Code scanning / SonarCloud

NoSQL operations should not be vulnerable to injection attacks High

Change this code to not construct database queries directly from user-controlled data. See more on SonarCloud
if (existingUser) {
return res
.status(400)
Expand Down Expand Up @@ -107,11 +109,12 @@ app.get("/users/search", async (req, res) => {
}

// Encuentra los amigos del usuario actual
const un = username;
const currentUserFriends = currentUser.friends;

// Encuentra todos los usuarios que no son amigos del usuario actual
const users = await User.find({
username: { $ne: username, $nin: currentUserFriends },
username: { $ne: un, $nin: currentUserFriends },
});

res.json(users);
Expand Down
9 changes: 8 additions & 1 deletion webapp/src/pages/Config/Config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ describe("Config Component", () => {
expect(
screen.getByText("Tiempo total (Batería de sabios)")
).toBeInTheDocument();
expect(screen.getByText("Aplicar cambios")).toBeInTheDocument();
const button = screen.getByText("Aplicar cambios");
expect(button).toBeInTheDocument();
button.click();

const checks = screen.getAllByRole("checkbox");
console.log(checks)
checks[0].checked = true;
button.click();
});
});

0 comments on commit aca33d4

Please sign in to comment.