Skip to content

Commit

Permalink
Hacktoberfest-password-Crediability-29-Top-secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
RonitBaranwal committed Oct 3, 2023
1 parent 4ba5845 commit 394f899
Show file tree
Hide file tree
Showing 4 changed files with 5,866 additions and 56 deletions.
14 changes: 14 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ app.get("/login",function(req,res){
app.get("/about",function(req,res){
res.render("about");
});
app.post("/register", function (req, res) {
const { username, password } = req.body;

// Server-side password validation
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
if (!regex.test(password)) {
return res.status(400).render("register", { error: "Invalid password" });
}

// Continue with registration logic
// ... (create user account, save to database, etc.)

res.status(200).send("Registration successful");
});
app.get("/register",function(req,res){
res.render("register");
});
Expand Down
Loading

0 comments on commit 394f899

Please sign in to comment.