function deleteUser(clientToken, callback) {
  async.waterfall([
    function(next) {
      Session.findUser(clientToken, next);
    },
    function(userId, next) {
      Marker.removeAll(userId, function(err) {
        if (err) {
          next(err);
        } else {
          next(null, userId);
        }
      });
    },
    function(userId, next) {
      // Remove user from UserMongoModel
      UserMongoModel.findByIdAndRemove(userId,
        function(err) {
          if (err) {

            // TODO: Error message?
            next(err);
          } else {
            next(null, userId);
          }
        }
      );
    },
    function(userId, next) {

      // Removes session from sessions collection
      Session.destroyAll(userId, next);
    }
  ], callback);
}
// Takes a token string and deletes the associated user, markers and session from MongoDB
Takes a token string and deletes the associated user, markers and session from MongoDB
Takes a token string and deletes the associated user markers and session from MongoDB
function deleteUser(clientToken, callback) {
  async.waterfall([
    function(next) {
      Session.findUser(clientToken, next);
    },
    function(userId, next) {
      Marker.removeAll(userId, function(err) {
        if (err) {
          next(err);
        } else {
          next(null, userId);
        }
      });
    },
    function(userId, next) {
      UserMongoModel.findByIdAndRemove(userId,
        function(err) {
          if (err) {
            next(err);
          } else {
            next(null, userId);
          }
        }
      );
    },
    function(userId, next) {
      Session.destroyAll(userId, next);
    }
  ], callback);
}
function deleteUser ( clientToken , callback ) { async . waterfall ( [ function ( next ) { Session . findUser ( clientToken , next ) ; } , function ( userId , next ) { Marker . removeAll ( userId , function ( err ) { if ( err ) { next ( err ) ; } else { next ( null , userId ) ; } } ) ; } , function ( userId , next ) { UserMongoModel . findByIdAndRemove ( userId , function ( err ) { if ( err ) { next ( err ) ; } else { next ( null , userId ) ; } } ) ; } , function ( userId , next ) { Session . destroyAll ( userId , next ) ; } ] , callback ) ; }
Takes a token string and deletes the associated user, markers and session from MongoDB
Takes a token string and deletes the associated user markers and session from MongoDB
// Remove user from UserMongoModel // TODO: Error message? // Removes session from sessions collection