diff --git a/server/src/policies/AuthenticationControllerPolicy.js b/server/src/policies/AuthenticationControllerPolicy.js index 93878894687a27b25e38ae2500e7956f22ebcab9..d93a56c27476af7ca1c82fe115de2de60ec1510a 100644 --- a/server/src/policies/AuthenticationControllerPolicy.js +++ b/server/src/policies/AuthenticationControllerPolicy.js @@ -2,16 +2,16 @@ const Joi = require('joi') module.exports={ - register(reg, res, next){ + register(req, res, next){ - const schema ={ + const schema =Joi.object({ email: Joi.string().email(), password: Joi.string().regex( - new regExp('^[a-zA-Z0-9]{8-32}$') + new RegExp('^[a-zA-Z0-9]{8-32}$') ) - } - - const {error, value} = Joi.Validate(req.body, schema) + }) + + const {error, value} = schema.validate(req.body) if(error){ switch(error.details[0].context.key){ @@ -25,7 +25,7 @@ module.exports={ case 'password': res.status(400).send({ error: ' The password provided failed to match the following rules <br> 1.It must contain only the following characters: lower case, upper case, numerics <br> 2.It must be at least 8 characters in lenght and not greater than 32 characters' - + }) break @@ -36,13 +36,13 @@ module.exports={ }) } - + } else{ next() } - + } }