Created
July 24, 2016 14:47
-
-
Save miki2826/66d64f6d040c7093da82ac56d9c16b05 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
passport.use(new FacebookStrategy({ | |
clientID: FACEBOOK_APP_ID, | |
clientSecret: FACEBOOK_APP_SECRET, | |
callbackURL: "http://localhost:3000/auth/facebook/callback" | |
}, | |
function(accessToken, refreshToken, profile, cb) { | |
User.findOrCreate({ facebookId: profile.id }, function (err, user) { | |
return cb(err, user); | |
}); | |
} | |
)); | |
app.get('/auth/facebook', | |
passport.authenticate('facebook')); | |
app.get('/auth/facebook/callback', | |
passport.authenticate('facebook', { failureRedirect: '/login' }), | |
function(req, res) { | |
// Successful authentication, redirect home. | |
res.redirect('/'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment