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