This commit is contained in:
quoije
2023-05-10 21:03:22 -04:00
parent ef1b411c12
commit bd732815c7
1304 changed files with 192970 additions and 5407 deletions
+42 -1
View File
@@ -1,4 +1,5 @@
const db = require("../models");
const dev = require("deep-email-validator");
const ROLES = db.ROLES;
const User = db.user;
@@ -51,9 +52,49 @@ checkRolesExisted = (req, res, next) => {
next();
};
validateEmail = async (req, res, next) => {
if (req.body.email) {
const emailRes = await dev.validate({
email: req.body.email,
sender: req.body.email,
validateRegex: true,
valideMx: true,
validateTypo: true,
validateDisposable: true,
validateSMTP: false,
})
console.log((emailRes.valid))
if (!emailRes.valid) {
res.status(400).send({
message: "oof! ton email est pas valide loco"
});
return;
}
}
next();
};
checkPassLimit = (req, res, next) => {
if (req.body.password) {
for (let i = 0; i < req.body.password.length; i++) {
if (req.body.password.length <= 8) {
res.status(400).send({
message: "oof! ce password ne respecte pas les limitations en cours."
});
return;
}
}
}
next();
};
const verifySignUp = {
checkDuplicateUsernameOrEmail,
checkRolesExisted
checkRolesExisted,
validateEmail,
checkPassLimit
};
module.exports = verifySignUp;