这是我的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
... 我能怎么做?
您可以使用自定义回调 http://passportjs.org/docs/authenticate#custom-callback动态生成回调 url,因为 req 对象在其中可用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)