-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
PalB/server/controllers/index.js
Lines 38 to 58 in 9ded714
| const addUsers = (req, res, next) => { | |
| const schema = Joi.object().keys({ | |
| name: Joi.string().alphanum().min(3).max(20) | |
| .required(), | |
| email: Joi.string().email().required(), | |
| password: Joi.string().regex(/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)^\w{6,}$/).required(), | |
| confirm: Joi.ref('password'), | |
| avatar: Joi.string().required(), | |
| }); | |
| const { error, value } = schema.validate(req.body); | |
| if (error) { | |
| res.send(error.message); | |
| } else { | |
| checkUser(value).then(({ rows }) => { | |
| if (rows.length !== 0) res.send('Email is already exist'); | |
| else { | |
| addUser(value).then(() => res.redirect('/')).catch((err) => { next(err); }); | |
| } | |
| }); | |
| } | |
| }; |
Incorrect sign up :
1- you didn't hash password
2- you didn't use signup query as it required
3- you didn't send cookie