title: How can I redirect User to "parks/:campgroundId" page from the login post route,Using Nodejs and Passport
body: <p><strong>Hi</strong> </p>
  
  <p>I have problem redirecting to a page with <strong>ID</strong> from my <strong>login post route</strong>, here is my code:</p>
  
  <pre><code>//Sign In Routes
  app.get("/login", function(req, res){
      req.flash("error", "Please login first!");
      res.render("login");
  });
  //handling login logic
  app.post('/login', passport.authenticate("local", {failureRedirect: "/login"}), function(req, res) {
      Campground.find({}, function(err, allCampgrounds){
          if(err){
              console.log(err);
          }else{ 
              allCampgrounds.forEach(function(theCampground){
                  if(theCampground.members === req.user._id){
                      res.redirect("/parks/" + theCampground.id);
                  }
              });
          }
      });
  </code></pre>
  
  <p>this code redirects me back to "/login" page when i'm sure user is registered by that username and password. </p>
  
  <p>Any help will be appreciated.</p>
  
  <p>Thank you!</p>