注销功能正常工作。单击注销后,它将带您到Google登录页面。我试图让“退出”按钮返回首页,而不是再次看到Google登录页面。也许我只是不正确地理解护照。看来我在正确的轨道上,可能只是我看不到的路线问题
我尝试声明var _LoggedIn =(req.isAuthenticated()?true:false);
const router = require('express').Router();
const passport = require('passport');
router.get('/login', (req, res) => {
res.render('login', { user: req.user });
});
router.get('/logout', (req, res) => {
req.logout();
req.session = null;
res.redirect('https://accounts.google.com/logout') = () => {
window.location.href ="http://localhost:3000";
}
});
router.get('/google', passport.authenticate('google', {
scope: ['profile']
}));
router.get('/google/redirect', passport.authenticate('google'), (req,
res) => {
res.redirect('/profile');
});
module.exports = router;
当单击主页上的注销时,它会将您发送到google登录。我确实要保留注销功能,只是不要让它转到google。我想回到首页