这是我的登录功能atm:
app.post("/login", passport.authenticate("local", {
failureRedirect: "/login?error=1"
}), function (req, res) {
res.redirect(req.body.url || "/");
});
我需要将req.body.url放在failureRedirect url中,所以看起来应该是这样的:
app.post("/login", passport.authenticate("local", {
failureRedirect: "/login?error=1&url=" + (req.body.url || "/")
}), function (req, res) {
res.redirect(req.body.url || "/");
});
它无法工作,因为req变量仅在post
的回调中被引用...我该怎么办?