【发布时间】:2016-07-18 06:17:47
【问题描述】:
这是我的登录功能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的回调中被初始化所以不能工作...怎么办?
【问题讨论】:
标签: node.js express passport.js