forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/Arquisoft/wiq_es1a into …
…develop
- Loading branch information
Showing
2 changed files
with
13 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters