Skip to content

Instantly share code, notes, and snippets.

@emmaodia
Created January 24, 2020 02:35
Show Gist options
  • Save emmaodia/5405cdcc39ab403938bdca263ec4f5fb to your computer and use it in GitHub Desktop.
Save emmaodia/5405cdcc39ab403938bdca263ec4f5fb to your computer and use it in GitHub Desktop.
//Routes
//User gets here upon successful login
router.get('/home', (req, res) => {
res.json({ user: user });
});
//This is so you know if a Login attempt failed
router.get('/login', (req, res) => {
res.json({msg: "login failed"});
});
//This endpoint connects the User to Facebook
router.get('/login/facebook', passport.authenticate('facebook'));
//This endpoint is the Facebook Callback URL and on success or failure returns a response to the app
router.get('/return', passport.authenticate('facebook', {
failureRedirect: '/login' }), (req, res) => {
res.redirect('/user/home');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment