text: 'use strict';
  
  // User routes use users controller
  var users = require('../controllers/users');
  
  module.exports = function(app, passport) {
  
      app.get('/logout', users.signout);
      app.get('/users/me', users.me); 
  
      // Setting up the users api
      app.post('/register', users.create);
  
      // Setting up the userId param
      app.param('userId', users.user);
  
      // AngularJS route to check for authentication
      app.get('/loggedin', function(req, res) {
          res.send(req.isAuthenticated() ? req.user : '0');
      });
  
      // Setting the local strategy route
      app.post('/login', passport.authenticate('local', {
          failureFlash: true
      }), function (req,res) {
          res.send(req.user);
      });
  
      // Setting the facebook oauth routes
      app.get('/auth/facebook', passport.authenticate('facebook', {
          scope: ['email', 'user_about_me'],
          failureRedirect: '#!/login'
      }), users.signin);
  
      app.get('/auth/facebook/callback', passport.authenticate('facebook', {
          failureRedirect: '#!/login'
      }), users.authCallback);
  
      // Setting the github oauth routes
      app.get('/auth/github', passport.authenticate('github', {
          failureRedirect: '#!/login'
      }), users.signin);
  
      app.get('/auth/github/callback', passport.authenticate('github', {
          failureRedirect: '#!/login'
      }), users.authCallback);
  
      // Setting the twitter oauth routes
      app.get('/auth/twitter', passport.authenticate('twitter', {
          failureRedirect: '#!/login'
      }), users.signin);
  
      app.get('/auth/twitter/callback', passport.authenticate('twitter', {
          failureRedirect: '#!/login'
      }), users.authCallback);
  
      // Setting the google oauth routes
      app.get('/auth/google', passport.authenticate('google', {
          failureRedirect: '#!/login',
          scope: [
              'https://www.googleapis.com/auth/userinfo.profile',
              'https://www.googleapis.com/auth/userinfo.email'
          ]
      }), users.signin);
  
      app.get('/auth/google/callback', passport.authenticate('google', {
          failureRedirect: '#!/login'
      }), users.authCallback);
  
      // Setting the linkedin oauth routes
      app.get('/auth/linkedin', passport.authenticate('linkedin', {
          failureRedirect: '#!/login',
          scope: [ 'r_emailaddress' ]
      }), users.signin);
  
      app.get('/auth/linkedin/callback', passport.authenticate('linkedin', {
          failureRedirect: '#!/login'
      }), users.authCallback);
  
  };
  