londonappbrewery / Authentication-Secrets

Companion Code for the Authentication Module on The Complete 2019 Web Development Bootcamp
https://www.appbrewery.co
440 stars 524 forks source link

does not get secret file after registering with google instead of secret file i get js object (my id and google id). #35

Open prince-sunsara opened 1 year ago

prince-sunsara commented 1 year ago

app.get("/auth/google", passport.authenticate("google", { scope: ["profile"] }), function(req, res) { // Successfull authentication, redirect to secrets. res.redirect("/auth/google/secrets"); } );

app.get("/auth/google/secrets", passport.authenticate('google', { failureRedirect: "/login" }), function(req, res) { // Successful authentication, redirect to secrets. res.redirect("/secrets"); });

app.post("/register", (req, res) => { User.register({ username: req.body.username}, req.body.password, (err, user) => { if(err){ // console.log(err); res.redirect("/register"); } else { passport.authenticate("local")(req, res, (err) => { if(!err) res.redirect("/secrets"); else console.log(err); }); } }); });

app.get("/secrets", (req, res) => { if(req.isAuthenticated()){ res.render("secrets"); } else { res.redirect("/login"); } });

any problem here ?