Q:

Error: Can't set headers after they are sent

I'm trying to do a login function but the Error: Can't set headers after they are sent is keep showing up in my terminal, based on my understanding this error is causing by res but I can't find the error in my code..
this is what I have so far:
login function
this.handleLoginRequest = function(req, res, next) {
        "use strict";
        var data = req.body;

        users.validateLogin(data, function(err, user) {
            "use strict";
            if(err) {
            res.send(400, err.message);
            }else{
                sessions.startSession(data, function(err, session_id) {
                            "use strict";
                    if (err) return next(err);
                            res.cookie('session', session_id);
                            res.send(200);
                });
           }
        });
    }

validateLogin function
this.validateLogin = function(data, callback) {
        "use strict";

        // Callback to pass to MongoDB that validates a user document
        function validateUserDoc(err, user) {
            "use strict";

            if (err) return callback(err, null);

            if (user) {
                if (bcrypt.compareSync(data.password, user.password)) {
                    callback(null, user);
                } else {
                    callback(new Error("Invalid password/email"), null);
                }
            }else{
                // no such user error 
                    callback(new Error("no such user"), null);
            }

        }

        users.findOne({ '_id' : data.email }, validateUserDoc);
        process.nextTick(function() {
                callback(null, data);
              });
    }

A:

It looks like the callback passed to validateLogin is called twice:

once from validateUserDoc;
once from the process.nextTick callback (that part seems to be some left-over code);

