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 ?