护照身份验证后无法检索用户
Failing to retrieve user after passport authentication
如果身份验证成功,则用户将被重定向到“/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
})
})
在控制台中,当 运行 我看到的程序 "Attempting to render profile" 然后它显示用户对象,但在浏览器中,它似乎永远加载。它卡在 res.render("profile.jade", ... 等等
如果我关闭页面加载,关闭后控制台会立即显示 "GET /profile - - ms - -"
我的护照配置文件,使用 Google Oauth2 和 MySQL 看起来像这样。 https://gist.github.com/anonymous/6265a7779154a087b833
因此,解决方法是将正确的变量传递给 jade 模板
https://gist.github.com/anonymous/6265a7779154a087b833 行:63
你没有将 googleid 插入数据库,你怎么能把它弄出来
如果身份验证成功,则用户将被重定向到“/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
})
})
在控制台中,当 运行 我看到的程序 "Attempting to render profile" 然后它显示用户对象,但在浏览器中,它似乎永远加载。它卡在 res.render("profile.jade", ... 等等
如果我关闭页面加载,关闭后控制台会立即显示 "GET /profile - - ms - -"
我的护照配置文件,使用 Google Oauth2 和 MySQL 看起来像这样。 https://gist.github.com/anonymous/6265a7779154a087b833
因此,解决方法是将正确的变量传递给 jade 模板
https://gist.github.com/anonymous/6265a7779154a087b833 行:63 你没有将 googleid 插入数据库,你怎么能把它弄出来