function findUserByToken(clientToken, callback) {
  SessionMongoModel.findOne({ token: clientToken }, function(err, session) {
    if (err) {

      // TODO: Error message?
      callback(err, null);
    } else if (!session) {
      callback({
        code    : 400,
        message : 'Session not found.'
      });
    } else {
      callback(null, session.userId);
    }
  });
}
// Takes a token string as an argument and returns ths userId to the callback
Takes a token string as an argument and returns ths userId to the callback
Takes a token string as an argument and returns ths userId to the callback
function findUserByToken(clientToken, callback) {
  SessionMongoModel.findOne({ token: clientToken }, function(err, session) {
    if (err) {
      callback(err, null);
    } else if (!session) {
      callback({
        code    : 400,
        message : 'Session not found.'
      });
    } else {
      callback(null, session.userId);
    }
  });
}
function findUserByToken ( clientToken , callback ) { SessionMongoModel . findOne ( { token : clientToken } , function ( err , session ) { if ( err ) { callback ( err , null ) ; } else if ( ! session ) { callback ( { code : 400 , message : 'Session not found.' } ) ; } else { callback ( null , session . userId ) ; } } ) ; }
Takes a token string as an argument and returns ths userId to the callback
Takes a token string as an argument and returns ths userId to the callback
// TODO: Error message?