<commit_before>var utils = require( "./utilities" );

module.exports.loadOwnProject = function( Project ) {
  return function( req, res, next, id ) {
    Project.find({ id: id, email: req.session.email }, function( err, project ) {
      if ( err ) {
        next( utils.error( 500, err ));
      }
      if ( !project ) {
        next( utils.error( 404 ));
      }

      res.locals.project = project;
      next();
    });
  };
};

module.exports.loadAnyProject = function( Project ) {
  return function( req, res, next, id ) {
    Project.find({ id: id }, function( err, project ) {
      if ( err ) {
        next( utils.error( 500, err ));
      }
      if ( !project ) {
        next( utils.error( 404 ));
      }

      res.locals.project = project;
      next();
    });<commit_msg>Fix Bug 885082 - [Crash] TypeError: Cannot read property '0' of undefined @lib/project.js:188, part 2<commit_after>var utils = require( "./utilities" );

module.exports.loadOwnProject = function( Project ) {
  return function( req, res, next, id ) {
    Project.find({ id: id, email: req.session.email }, function( err, project ) {
      if ( err ) {
        next( utils.error( 500, err ));
        return;
      }
      if ( !project ) {
        next( utils.error( 404 ));
        return;
      }

      res.locals.project = project;
      next();
    });
  };
};

module.exports.loadAnyProject = function( Project ) {
  return function( req, res, next, id ) {
    Project.find({ id: id }, function( err, project ) {
      if ( err ) {
        next( utils.error( 500, err ));
        return;
      }
      if ( !project ) {
        next( utils.error( 404 ));
        return;
      }

      res.locals.project = project;
      next();
    });
{'fraction_non_alphanumeric': 0.15531177829099307, 'fraction_numerical': 0.02020785219399538, 'mean_word_length': 2.0726950354609928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3051515', 'n_tokens_mistral': 582, 'n_tokens_neox': 555, 'n_words': 146}