Last active
July 9, 2019 07:49
-
-
Save christianstrang/35b85de745af6891f3d0127ead4e62b1 to your computer and use it in GitHub Desktop.
SailsJS Facebook PassportController
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
/** | |
* PassportController | |
* | |
* @description :: Server-side actions for handling incoming requests. | |
* @help :: See https://sailsjs.com/docs/concepts/actions | |
*/ | |
var passport = require('passport'); | |
module.exports = { | |
facebookAuth: function(req, res, next) { | |
passport.authenticate('facebook', { scope: ['email']})(req, res, next); | |
}, | |
facebookCallback: function(req, res, next) { | |
passport.authenticate('facebook', function(err, user) { | |
console.log('facebook credentials'); | |
console.log(user); | |
res.json(user); | |
})(req, res, next); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment