-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
PalB/server/controllers/index.js
Lines 19 to 32 in 9ded714
| const getUsers = (req, res, next) => { | |
| const schema = Joi.object().keys({ | |
| email: Joi.string().email().required(), | |
| password: Joi.string().regex(/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)^\w{6,}$/).required(), | |
| }); | |
| const { error, value } = schema.validate(req.body); | |
| if (error) { | |
| res.send(error.message); | |
| } else { | |
| getUser(value).then(({ rows }) => { | |
| res.cookie('name', rows[0].name).redirect('/'); | |
| }).catch((err) => { next(err); }); | |
| } | |
| }; |
Incorrect function to handle log in route :
your code here isn't clear and need a lot of edits and these the main important points that you must consider :
1-you didn't have a hashed password in your database.
2- You didn't check if the user is registered correctly.
3- you sent cookie without hashing it