wow
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user