feat: email regex check

This commit is contained in:
amhsirak
2025-07-12 01:38:14 +05:30
parent a56bef3f62
commit 9d7661231a

View File

@@ -33,6 +33,14 @@ router.post("/register", async (req, res) => {
}); });
} }
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
return res.status(400).json({
error: "VALIDATION_ERROR",
code: "register.validation.invalid_email_format"
});
}
if (!password || password.length < 6) { if (!password || password.length < 6) {
return res.status(400).json({ return res.status(400).json({
error: "VALIDATION_ERROR", error: "VALIDATION_ERROR",
@@ -166,7 +174,7 @@ router.get("/logout", async (req, res) => {
error: process.env.NODE_ENV === 'development' ? error : undefined error: process.env.NODE_ENV === 'development' ? error : undefined
}); });
} }
} }
); );
router.get( router.get(
@@ -811,7 +819,7 @@ router.get("/airtable/bases", requireSignIn, async (req: Request, res) => {
// Update robot with selected base // Update robot with selected base
router.post("/airtable/update", requireSignIn, async (req: Request, res) => { router.post("/airtable/update", requireSignIn, async (req: Request, res) => {
const authenticatedReq = req as AuthenticatedRequest; const authenticatedReq = req as AuthenticatedRequest;
const { baseId, robotId , baseName, tableName, tableId} = req.body; const { baseId, robotId, baseName, tableName, tableId } = req.body;
if (!baseId || !robotId) { if (!baseId || !robotId) {
return res.status(400).json({ message: "Base ID and Robot ID are required" }); return res.status(400).json({ message: "Base ID and Robot ID are required" });