module.exports = {

  setUp: function(self, passport){
    return function(){
      Array.prototype.push.call(arguments, passport);
      self.login.apply(this, arguments);
    };
  },

  login: function(req, res, next, passport){

    passport.authenticate('local', function(err, user, info) {
      if (err) { return next(err); }

      if (!user) { 
        if(info){ return res.send(info); }

        //TODO Need to improve this
        return res.redirect('/');
      }

      req.logIn(user, function(err) {
        if (err) { return next(err); }
        return res.redirect('/');
      });

    })(req, res, next);

  },

  logout: function(req, res){
    req.logout();
    res.redirect('/');
  }


};

@@ -392,79 +392,8 @@
 ); %7D
-%0A%0A        //TODO Need to improve this%0A        return res.redirect('/');
 %0A   
@@ -490,36 +490,47 @@
  return res.
-redirect('/'
+send(%7Buser: user.email%7D
 );%0A      %7D);
@@ -604,38 +604,53 @@
 req.
-logout();%0A    res.redirect('/'
+session.destroy();%0A    res.send(%7Buser: false%7D
 );%0A 

Send current user