Skip to content

Incorrect signup new user #45

@AlaaTaima

Description

@AlaaTaima

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

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