Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Log in #46

Open
AlaaTaima opened this issue Mar 4, 2020 · 0 comments
Open

Incorrect Log in #46

AlaaTaima opened this issue Mar 4, 2020 · 0 comments
Labels

Comments

@AlaaTaima
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant