Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.get('/auth/facebook/menu', function(req,res,next) {
- // url parameter ?state=subpage is passed to login
- // this can be used for routing after callback
- let param = req.query.state;
- passport.authenticate('facebook', { state: param })(req,res,next);
- });
- app.get('/auth/facebook/callback', passport.authenticate(
- 'facebook',
- { failureRedirect: '/' }),
- function(req, res) {
- let state = req.query.state;
- // redirect user depending from
- // where he came from
- switch(state) {
- case 'subpage':
- res.redirect('/subpage');
- break;
- default:
- res.redirect('/');
- }
- });
Add Comment
Please, Sign In to add comment