Connorelsea
Connorelsea

Reputation: 2438

Failing to retrieve user after passport authentication

If authentication succeeds, then the user is redirected to the "/profile" route, as the following code indicates.

app.get(
        "/auth/google/callback",
        passport.authenticate("google", { successRedirect: "/profile", failureRedirect: "/failure" })
)

The route for the profile page looks like this.

app.get("/profile", function(req, res) {

    console.log("Attempting to render profile")
    console.log("USER: " + req.user)

    res.render("profile.jade", {
        user: req.user
    })
})

In the console, when running the program I see "Attempting to render profile" and then it shows the user object but then in the browser, it seems as if it loads eternally. It gets stuck on the res.render("profile.jade", ... etc.

If I close the page loading, right after I close it the console says "GET /profile - - ms - -"

My passport configuration file, using Google Oauth2 and MySQL looks like this. https://gist.github.com/anonymous/6265a7779154a087b833

Upvotes: 0

Views: 62

Answers (2)

R.A. Lucas
R.A. Lucas

Reputation: 1161

So, the fix was to pass the correct variable to the jade template

Upvotes: 1

trquoccuong
trquoccuong

Reputation: 2873

https://gist.github.com/anonymous/6265a7779154a087b833 line: 63 You didn't insert googleid to database how can you get that out

Upvotes: 0

Related Questions