title: Nodejs custom successRedirect page after login
body: <p>How can I make custom successRedirect page after login in node,js based on value from mysql user row? Something like that:</p>
  
  <pre><code>passport.use(new LocalStrategy(
      function(username, password, done) {
  
          var strQuery = "SELECT * FROM users WHERE username='"+username+"' and password_text='"+password+"'";
          connection.query( strQuery, function(err, users){
              if (err) { return done(err); }
  
              if (typeof users[0] == 'undefined' &amp;&amp; users.length == 0) {
                  return done(null, false, { message: 'Incorrect username or password' });
              }
              if (password != users[0].password_text ) {
                  return done(null, false, { message: 'Incorrect password.' });
              }
              return done(null, users[0]);
          });
      }
  ));
  
  passport.serializeUser(function(user, done) {
      done(null, user.id);
  });
  
  passport.deserializeUser(function(id, done, ) {
  
      var strQuery = "SELECT * FROM users WHERE id='"+id+"'";
      connection.query( strQuery, function(err, users){
          return done(null, users[0]);
      });
  });
  
  
  
  app.post('/login',
      passport.authenticate('local', { failureRedirect: '/login', failureFlash: true }),
      function(req, res, next) { 
          if (req.user.userlevel &gt; 3) {         // Here is my problem I dont't know how get userlevel value
              return res.redirect('/index1');
          } else {
              res.redirect('/index2');
          }
      });
  </code></pre>
  
  <p>I don't know why is my code not working... <code>userlevel</code> is real column in <code>users</code> table 
  Thanks for any advise</p>