var async		= require('async');
var User 		= require('../models/User');

exports.signup = function(req, res){
	console.log('user.signup');

	var email 		 	= req.body.email;
  	var firstName 	 	= req.body.firstName;
  	var lastName	 	= req.body.lastName;
  	var password 	 	= req.body.password;

  	if (!email || !firstName || !lastName || !password){
		return handleError(res, {
			status: 400,
			message: 'Missing parameters'
		})	
	}
	var params = {
		email		: email,
		firstName	: firstName,
		lastName	: lastName,
		password 	: password
	}

	async.waterfall([

		function createUser(next){
			User.signup(params, next);
		},
		function createSession(user, next){
			user.createSession(function (token){				
				next(null, user);
			})
		}
	],
	function (err, user){
		if(err) return handleError(res, err); 

		res.json({
			user: user
		});
	})
	
}

function handleError(res, err){
	var status = err.status || 500;
	res.status(status);
	return res.json({
		errors: [err]
	});
};
@@ -63,16 +63,64 @@
 /User');
+%0Avar constants %09= require('../utils/constants');
 %0A%0Aexport
@@ -747,20 +747,79 @@
 (token)%7B
+%0A
 %09%09%09%09
+res.setHeader(constants.AUTH_TOKEN, token);//add as header
 %0A%09%09%09%09nex

return new session token on signup