2015-06-29 22:51:29 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module dependencies.
|
|
|
|
*/
|
|
|
|
var passport = require('passport');
|
|
|
|
|
|
|
|
module.exports = function(app) {
|
|
|
|
// User Routes
|
|
|
|
var users = require('../../app/controllers/users.server.controller');
|
|
|
|
|
|
|
|
// Setting up the users profile api
|
2015-06-30 07:28:29 +00:00
|
|
|
app.route('/users/me').get(users.requiresLogin, users.me);
|
|
|
|
app.route('/users').put(users.requiresLogin, users.update);
|
|
|
|
app.route('/users/accounts').delete(users.requiresLogin, users.removeOAuthProvider);
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-07-27 18:11:43 +00:00
|
|
|
// Setting up the users account verification api
|
|
|
|
app.route('/auth/verify/:token').get(users.validateVerificationToken);
|
2015-07-29 00:16:44 +00:00
|
|
|
app.route('/auth/verify').post(users.resendVerificationEmail);
|
2015-07-21 23:25:45 +00:00
|
|
|
|
2015-06-29 22:51:29 +00:00
|
|
|
// Setting up the users password api
|
2015-06-30 06:12:32 +00:00
|
|
|
app.route('/users/password').post(users.requiresLogin, users.changePassword);
|
2015-06-29 22:51:29 +00:00
|
|
|
app.route('/auth/forgot').post(users.forgot);
|
|
|
|
app.route('/auth/reset/:token').get(users.validateResetToken);
|
|
|
|
app.route('/auth/reset/:token').post(users.reset);
|
|
|
|
|
|
|
|
// Setting up the users authentication api
|
|
|
|
app.route('/auth/signup').post(users.signup);
|
|
|
|
app.route('/auth/signin').post(users.signin);
|
|
|
|
app.route('/auth/signout').get(users.signout);
|
|
|
|
|
2015-08-07 21:02:44 +00:00
|
|
|
// // Setting the facebook oauth routes
|
|
|
|
// app.route('/auth/facebook').get(passport.authenticate('facebook', {
|
|
|
|
// scope: ['email']
|
|
|
|
// }));
|
|
|
|
// app.route('/auth/facebook/callback').get(users.oauthCallback('facebook'));
|
|
|
|
|
|
|
|
// // Setting the twitter oauth routes
|
|
|
|
// app.route('/auth/twitter').get(passport.authenticate('twitter'));
|
|
|
|
// app.route('/auth/twitter/callback').get(users.oauthCallback('twitter'));
|
|
|
|
|
|
|
|
// // Setting the google oauth routes
|
|
|
|
// app.route('/auth/google').get(passport.authenticate('google', {
|
|
|
|
// scope: [
|
|
|
|
// 'https://www.googleapis.com/auth/userinfo.profile',
|
|
|
|
// 'https://www.googleapis.com/auth/userinfo.email'
|
|
|
|
// ]
|
|
|
|
// }));
|
|
|
|
// app.route('/auth/google/callback').get(users.oauthCallback('google'));
|
|
|
|
|
|
|
|
// // Setting the linkedin oauth routes
|
|
|
|
// app.route('/auth/linkedin').get(passport.authenticate('linkedin'));
|
|
|
|
// app.route('/auth/linkedin/callback').get(users.oauthCallback('linkedin'));
|
|
|
|
|
|
|
|
// // Setting the github oauth routes
|
|
|
|
// app.route('/auth/github').get(passport.authenticate('github'));
|
|
|
|
// app.route('/auth/github/callback').get(users.oauthCallback('github'));
|
2015-06-29 22:51:29 +00:00
|
|
|
|
|
|
|
// Finish by binding the user middleware
|
|
|
|
app.param('userId', users.userByID);
|
|
|
|
};
|