Created
January 24, 2020 02:35
-
-
Save emmaodia/5405cdcc39ab403938bdca263ec4f5fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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