Skip to content

Instantly share code, notes, and snippets.

@christianstrang
Last active July 9, 2019 07:49
Show Gist options
  • Save christianstrang/35b85de745af6891f3d0127ead4e62b1 to your computer and use it in GitHub Desktop.
Save christianstrang/35b85de745af6891f3d0127ead4e62b1 to your computer and use it in GitHub Desktop.
SailsJS Facebook PassportController
/**
* 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