i finaly find the soluction
the soluction to my problem
const authenticateUser = async (connection, req, res) => {
const user = await User.findUser(connection, req.body.username)
if(!user){
return res.render('login/login',{error: true})
}
if(!await bcrypt.compare(req.body.password, user.password)){
return res.render('login/login', {error: true})
}
else{
// user.password = undefined
//const nivel = await User.findnivel(connection, req.body.username)
if(user.user_type_id==1){
req.session.user = user
res.locals.user = user
res.redirect('/Administration');
}else if(user.user_type_id==2){
// req.session.nivel = nivel
console.log(2);
// res.redirect('/Users')
}else if(user.nivel==3){
// req.session.nivel = nivel
console.log(3);
// res.redirect('/Administration')
}else if(user.user_type_id==4){
// req.session.nivel = nivel
console.log(4);
// res.redirect('/Administration')
}
else if(user.user_type_id==5){
// req.session.nivel = nivel
console.log(5);
// res.redirect('/Administration')
} else {
console.log("banned");
}
topic can be close