护照认证后无法检索用户

Failing to retrieve user after passport authentication

本文关键字:检索 用户 认证      更新时间:2023-09-26

如果身份验证成功,则将用户重定向到"/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("配置文件上。玉",…等。

如果我关闭页面加载,在我关闭它之后,控制台显示"GET/profile - - ms - -"

我的护照配置文件,使用谷歌Oauth2和MySQL看起来像这样。https://gist.github.com/anonymous/6265a7779154a087b833

所以,解决方法是将正确的变量传递给翡翠模板

https://gist.github.com/anonymous/6265a7779154a087b833 line: 63你没有在数据库中插入googleid怎么把它取出来呢