Skip to content

Commit

Permalink
added route to answer frontend with authenticated user info
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-flynn committed Jul 27, 2023
1 parent cf409ae commit 2a11cae
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion server/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const CLIENT_URL = 'http://localhost:8080/';
router.get(
'/google',
passport.authenticate('google', {
scope: ['profile'],
scope: ['profile', 'email'],
})
);
router.get(
Expand All @@ -19,5 +19,16 @@ router.get(
res.redirect(CLIENT_URL);
}
);
router.get('/user', (req, res) => {
console.log('authed?: ', req.isAuthenticated());
console.log('fun def?: ', `${req.isAuthenticated}`);
console.log('req.user: ', req.user);
res.json({ user: req.user });
});

router.get('/logout', (req, res) => {
req.logout();
res.redirect(CLIENT_URL);
});

module.exports = router;

0 comments on commit 2a11cae

Please sign in to comment.