Skip to content

Incorrect Log in  #46

@AlaaTaima

Description

@AlaaTaima

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions