Skip to content

Instantly share code, notes, and snippets.

@duartefdias
Created December 24, 2021 13:08
Show Gist options
  • Save duartefdias/8c0bd09d0fe1ec997c19711b4f68aee6 to your computer and use it in GitHub Desktop.
Save duartefdias/8c0bd09d0fe1ec997c19711b4f68aee6 to your computer and use it in GitHub Desktop.
// Test authenticated route
// Use this route to test if the front-end is able to access this route
// Front-end needs to pass the token in the request header (header name: "Authorization")
router.get('/authenticated/test', passport.authenticate('jwt', { session: false }), (req, res) => {
console.log('Authentication successful');
res.json({
message: 'Successfully authenticated',
user: req.user
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment