title: Why is passport.authenticate needed in a registration?
body: <p>I'm learning Passport, using local strategy and Mongoose, through passport-local-mongoose plugin. </p>
  
  <p>It makes sense to me in a /login for example, but I don't understand why passport.authenticate is needed in a registration, right after it having already taken place... </p>
  
  <p>Can anyone explain me, please? Also, what if it fails?</p>
  
  <p>The following code was taken from a tutorial, but I have found similar constructions all over.</p>
  
  <pre><code>router.post('/register', function(req, res) {
      User.register(new User({ username : req.body.username }),
        req.body.password, function(err, user) {
          if (err) {
              return res.status(500).json({err: err});
          }
          if (req.body.firstname) {
            user.firstname = req.body.firstname;
          }
          if (req.body.lastname) {
            user.lastname = req.body.lastname;
          }
          user.save(function(err,user) {
            passport.authenticate('local')(req, res, function () {
                return res.status(200).json({status: 'Registration Successful!'});
            });
          });
      });
  });
  </code></pre>