1

Since I'm landing on the login page from another url, I want the user redirected back to that url when he log on. But in order to do so I can't use passport as a middleware, ie I did

router.post("/login",function(req,res,next){
    var redirect= req.query.returnUrl || "index";
    passport.authenticate('local', { successRedirect: redirect,
                                   failureRedirect: 'login',
                                   failureFlash: true })(req,res,next);
});

ie I'm calling the middleware function manually, this because I need to extract some info from the request to proper form the redirect url. It works, but I don't know if there is a more compliant way in doing it. Can I use the middleware approach anyway?

Felice Pollano
  • 32,832
  • 9
  • 75
  • 115
  • See [this question (+ answer)](http://stackoverflow.com/questions/37634816/how-to-redirect-the-user-back-to-the-same-page-after-authentication/37634933). – robertklep Jul 21 '16 at 10:46

0 Answers0