Skip to content

Commit

Permalink
Añadida validación de contraseña
Browse files Browse the repository at this point in the history
  • Loading branch information
iyanfdezz committed Apr 18, 2024
1 parent a85fd14 commit 72090f5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions users/userservice/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ app.post("/adduser", async (req, res) => {

const username = req.body.username;

const passwordRegex = /^(?=.*[A-Z])(?=.*\d).{8,}$/;
if (!passwordRegex.test(password)) {
return res.status(401).json({
error: "Password must be at least 8 characters long, contain at least one uppercase letter, and at least one number.",
});
}

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

0 comments on commit 72090f5

Please sign in to comment.