Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fahimbabarpatel/142ce24a73bae8b0f91e to your computer and use it in GitHub Desktop.
Save fahimbabarpatel/142ce24a73bae8b0f91e to your computer and use it in GitHub Desktop.
app.get('/login', function(req, res, next) {
  passport.authenticate('local', function(err, user, info) {
    if (err) { return next(err); }
    if (!user) { return res.redirect('/login'); }
    req.logIn(user, function(err) {
      if (err) { return next(err); }
      return res.redirect('/users/' + user.username);
    });
  })(req, res, next);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment