So I have this method for a User object to check for an existing record.
User.findOrCreate = function(json){
    User.findOne({'email' : json.email}, function(err, user){
        if (!user){
            user = new User({
                id: json.id,
                email: json.email,
                f_name: json.first_name,
                l_name: json.last_name,
                gender: json.gender,
                locale: json.locale
            });
            user.save(function(err){
                if (err) return handleError(err);
                return user;
            });
        } else {
            return user;
        }
    });
}
so basically I want to return the variable "user" to the method findOrCreate, so that I can use it in another place like so:
var user = User.findOrCreate(profile._json);
But instead, user = undefined when I log it out. Having a lot of trouble with this. Can anyone help?
 
     
    