-
-
Save franklinjavier/a1d6affb7f0a766a6bb5 to your computer and use it in GitHub Desktop.
Passport.js Routes
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
"use strict"; | |
var passport = require('./passport'); | |
var config = { | |
redirectBack: redirectBack | |
} | |
function redirectBack(req, res) { | |
res.redirect(req.param('__back') && decodeURIComponent(req.param('__back')) || '/'); | |
} | |
function logout(req, res) { | |
req.logout(); | |
res.redirect('/auth/guest'); | |
} | |
function passportRoutes(app) { | |
app.get('/auth/guest', passport().authenticate('guest'), redirectBack); | |
app.get('/auth/twitter', passport().authenticate('twitter')); | |
app.get('/auth/twitter/callback', passport().authenticate('twitter'), config.redirectBack); | |
app.get('/auth/facebook', passport().authenticate('facebook')); | |
app.get('/auth/facebook/callback', passport().authenticate('facebook'), config.redirectBack); | |
app.get('/auth/linkedin', passport().authenticate('linkedin')); | |
app.get('/auth/linkedin/callback', passport().authenticate('linkedin'), config.redirectBack); | |
app.get('/auth/logout', logout); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment