【发布时间】:2015-08-01 12:01:40
【问题描述】:
如果认证成功,则用户被重定向到“/profile”路由,如下代码所示。
app.get(
"/auth/google/callback",
passport.authenticate("google", { successRedirect: "/profile", failureRedirect: "/failure" })
)
个人资料页面的路线如下所示。
app.get("/profile", function(req, res) {
console.log("Attempting to render profile")
console.log("USER: " + req.user)
res.render("profile.jade", {
user: req.user
})
})
在控制台中,运行程序时,我看到“尝试呈现配置文件”,然后它显示用户对象,但在浏览器中,它似乎永远加载。它卡在 res.render("profile.jade", ... etc.
如果我关闭页面加载,在我关闭它后控制台会显示“GET /profile - - ms - -”
我的护照配置文件,使用 Google Oauth2 和 MySQL 如下所示。 https://gist.github.com/anonymous/6265a7779154a087b833
【问题讨论】:
-
老实说,我对此不太了解,但是您不想像here 那样打电话给
res.send吗? -
你有你的
app.js或类似的东西来看看...我想知道是不是某些中间件或其他东西加载不正确?当你console.log(req)整个请求对象时,你得到什么了吗? -
现在它说“用户:[对象对象]”,然后永远加载。相同的代码。让我发送我的 app.js
-
不要使用
+,而是使用,,例如console.log("User", req);
标签: javascript node.js express oauth-2.0 passport.js