This is part of my code from the controller I am using to do validations for the login app, so everything is being inserted correctly into the database and its encrypted right, but the moment I try to submit user data it fails to validate the password, says the errors it's at the bcrypt. compare, I put the right one and even if I put the wrong it should redirect me to Home, instead the program crashes.
Error: Illegal arguments: undefined, string
at _async (C:\Users\CHINO\Desktop\Sistema-Pre-Escolar-Manitas-De-Oro-main (1)\Sistema-Pre-Escolar-Manitas-De-Oro-main\node_modules\bcryptjs\dist\bcrypt.js:286:46)
at C:\Users\CHINO\Desktop\Sistema-Pre-Escolar-Manitas-De-Oro-main (1)\Sistema-Pre-Escolar-Manitas-De-Oro-main\node_modules\bcryptjs\dist\bcrypt.js:307:17
at new Promise (<anonymous>)
at Object.bcrypt.compare (C:\Users\CHINO\Desktop\Sistema-Pre-Escolar-Manitas-De-Oro-main (1)\Sistema-Pre-Escolar-Manitas-De-Oro-main\node_modules\bcryptjs\dist\bcrypt.js:306:20)
at C:\Users\CHINO\Desktop\Sistema-Pre-Escolar-Manitas-De-Oro-main (1)\Sistema-Pre-Escolar-Manitas-De-Oro-main\controllers\authController.js:31:6
at processTicksAndRejections (node:internal/process/task_queues:96:5)
AuthController.js :
exports.PostLogin = (req, res, next) => {
const password = req.body.password
const email = req.body.email
User.findOne({ where: {email : email}})
.then((user) => {
if (!user) {
flash.req("errors","Ha ocurrido un error al momento de ingresar el Correo electronico")
return res.redirect("/login")
}
bcrypt
.compare(password, user.password)
.then((result) =>{
if (result){
req.session.IsloggedIn=true
req.session.user = user
return req.session.save((err) =>
{
flash.req("errors","Contreseña invalida")
console.log("Error al momento de compare",err)
res.redirect("/")
});
}
res.redirect("/login")
});
req.body.passwordseems to beundefined. Can you verify with your debugger?passwordanduser.passwordso you know what you got?