diff --git a/app.js b/app.js index 5c150ff553..f5cb16f609 100755 --- a/app.js +++ b/app.js @@ -11,6 +11,10 @@ var mongoose = require('mongoose'); var passport = require('passport'); var expressValidator = require('express-validator'); +/** + * Create Express server. + */ + var app = express(); /** @@ -112,6 +116,11 @@ app.get('/api/aviary', apiController.getAviary); app.get('/api/paypal', apiController.getPayPal); app.get('/api/paypal/success', apiController.getPayPalSuccess); app.get('/api/paypal/cancel', apiController.getPayPalCancel); + +/** + * OAuth routes for sign-in. + */ + app.get('/auth/facebook', passport.authenticate('facebook', { scope: 'email' })); app.get('/auth/facebook/callback', passport.authenticate('facebook', { successRedirect: '/', failureRedirect: '/login' })); app.get('/auth/github', passport.authenticate('github')); @@ -120,6 +129,11 @@ app.get('/auth/google', passport.authenticate('google', { scope: 'profile email' app.get('/auth/google/callback', passport.authenticate('google', { successRedirect: '/', failureRedirect: '/login' })); app.get('/auth/twitter', passport.authenticate('twitter')); app.get('/auth/twitter/callback', passport.authenticate('twitter', { successRedirect: '/', failureRedirect: '/login' })); + +/** + * OAuth routes for API examples that require authorization. + */ + app.get('/auth/foursquare', passport.authorize('foursquare')); app.get('/auth/foursquare/callback', passport.authorize('foursquare', { failureRedirect: '/api' }), function(req, res) { res.redirect('/api/foursquare');