Advertisement

nodejs problem

Started by August 06, 2018 11:21 AM
1 comment, last by Pedro Alves 6 years, 3 months ago

i try make a login system with mysql when run de nodejs and open the firefox

 

page is not redirecting correctly

Firefox has detected that the server is redirecting the request to this address in a way that will never be completed.

     This problem can sometimes be caused by disabling or declining to accept cookies.

 

Hello

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

 

Hello

This topic is closed to new replies.

Advertisement