title: after successfully register, i'm not able to login in express
body: <p>after successful register with passport in express, when i try to login. it failed and i don't know which code is causing error. please help.
  here is my code.</p>
  
  <pre><code>router.post('/register',function(req,res){
  //fetch user info
  var firstName=req.body.firstName,
      lastName = req.body.lastName,
      mobile= req.body.mobile,
      email = req.body.email,
      password = req.body.password,
      newsConsent = req.body.newsConsent;
  
  var userInfo = {firstName: firstName, lastName: lastName, mobile: mobile, email:email, newsConsent: newsConsent };
  
  //register and create user
  User.register(new User(userInfo), password, function(error, userCreated)
   {
       if (error)
       {
          console.log(error);    
          //  req.flash("error", error.message);
           return res.render("auth/register");
       }
       else
       {
           req.login(userCreated, function(err) {
            if (err) {
              console.log(err);
              return next(err);
            }
            console.log(userCreated);
            return res.redirect('/');
          });
       }
   });
  </code></pre>
  
  <p>});</p>
  
  <p>//login route</p>
  
  <pre><code>router.post("/login", passport.authenticate("local", 
  {
      successRedirect: "/",
      failureRedirect: "/register"
  }), function(req, res){
      console.log(req.body);
  </code></pre>
  
  <p>});</p>
  
  <p>also please tell me how to know about the error in passport</p>