Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions backend/src/controllers/auth.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ const getGoogleClient = () => {
*/
export const signup = catchAsync(async (req, res) => {
const { name, email, password } = req.body;
try {
// STRICT PASSWORD VALIDATION GATEWAY
if (!password || password.length < 8) {
return res.status(400).json({ message: "Password must be at least 8 characters long" });
}

const complexityRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
if (!complexityRegex.test(password)) {
return res.status(400).json({
message: "Password must contain at least one uppercase letter, one lowercase letter, one number, and one special character"
});
}


const existing = await User.findOne({ email });
if (existing) {
return res.status(409).json({ message: "An account with this email already exists" });
Expand Down
Loading