Created
October 14, 2016 19:19
-
-
Save derzunov/4ebd92cb498d44aa6a80ef6150d901f3 to your computer and use it in GitHub Desktop.
your_cool_project/api/controllers/AuthController.js
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
var passport = require( 'passport' ); | |
module.exports = { | |
facebook: function( req, res, next ) { | |
return passport.authenticate('facebook', { | |
scope: ['email'] | |
})( req, res, next ); | |
}, | |
callback: function( req, res, next ) { | |
passport.authenticate('facebook', function(err, user) { | |
// Здесь мы наконец-то получили юзера нашего приложения и можем записать, например его в сессию | |
req.session.user = user; | |
// И перенаправить человека на нужный урл (например тот, с которого он пришёл), но в примере просто направлю в рут | |
res.redirect('/'); | |
})( req, res, next ); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment