Skip to content

Commit

Permalink
Merge pull request #123 from Arquisoft/password-validation
Browse files Browse the repository at this point in the history
Validación de contraseña
  • Loading branch information
iyanfdezz authored Apr 18, 2024
2 parents 29fb894 + 72090f5 commit 63f9930
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 108 deletions.
108 changes: 0 additions & 108 deletions statsservice/model/stats-getter.js

This file was deleted.

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 63f9930

Please sign in to comment.