mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 01:58:00 +08:00
30 lines
857 B
JavaScript
30 lines
857 B
JavaScript
module.exports = router => {
|
|
const { passport, HandleAuthPopupCallback } = require('services/passport');
|
|
|
|
/**
|
|
* Facebook auth endpoint, this will redirect the user immediatly to facebook
|
|
* for authorization.
|
|
*/
|
|
router.get(
|
|
'/api/v1/auth/facebook',
|
|
passport.authenticate('facebook', {
|
|
display: 'popup',
|
|
authType: 'rerequest',
|
|
scope: ['public_profile'],
|
|
})
|
|
);
|
|
|
|
/**
|
|
* Facebook callback endpoint, this will send the user a html page designed to
|
|
* send back the user credentials upon sucesfull login.
|
|
*/
|
|
router.get('/api/v1/auth/facebook/callback', (req, res, next) => {
|
|
// Perform the facebook login flow and pass the data back through the opener.
|
|
passport.authenticate(
|
|
'facebook',
|
|
{ session: false },
|
|
HandleAuthPopupCallback(req, res, next)
|
|
)(req, res, next);
|
|
});
|
|
};
|