function anonProject(req, res, next) {
  var name = `${req.params.org}/${req.params.repo}`;

  name = name.toLowerCase();

  Project.findOne({name: name})
    .populate('creator')
    .exec(function (err, project) {
      if (err) {
        return res.status(500).send({
          error: 'Failed to find project',
          info: err
        });
      }

      if (!project) {
        return res.status(404).send('Project not found');
      }

      if (!project.creator) {
        return res.status(400).send('Project malformed; project creator user is missing.');
      }

      req.project = project;
      req.accessLevel = User.projectAccessLevel(req.user, project);

      if (req.user && project.creator) {
        req.user.isProjectCreator = project.creator._id.toString() === req.user._id.toString();
      }

      next();
    });
}
function anonProject(req, res, next) {
  var name = `${req.params.org}/${req.params.repo}`;

  name = name.toLowerCase();

  Project.findOne({name: name})
    .populate('creator')
    .exec(function (err, project) {
      if (err) {
        return res.status(500).send({
          error: 'Failed to find project',
          info: err
        });
      }

      if (!project) {
        return res.status(404).send('Project not found');
      }

      if (!project.creator) {
        return res.status(400).send('Project malformed; project creator user is missing.');
      }

      req.project = project;
      req.accessLevel = User.projectAccessLevel(req.user, project);

      if (req.user && project.creator) {
        req.user.isProjectCreator = project.creator._id.toString() === req.user._id.toString();
      }

      next();
    });
}
function anonProject ( req , res , next ) { var name = ` ${ req . params . org } ${ req . params . repo } ` ; name = name . toLowerCase ( ) ; Project . findOne ( { name : name } ) . populate ( 'creator' ) . exec ( function ( err , project ) { if ( err ) { return res . status ( 500 ) . send ( { error : 'Failed to find project' , info : err } ) ; } if ( ! project ) { return res . status ( 404 ) . send ( 'Project not found' ) ; } if ( ! project . creator ) { return res . status ( 400 ) . send ( 'Project malformed; project creator user is missing.' ) ; } req . project = project ; req . accessLevel = User . projectAccessLevel ( req . user , project ) ; if ( req . user && project . creator ) { req . user . isProjectCreator = project . creator . _id . toString ( ) === req . user . _id . toString ( ) ; } next ( ) ; } ) ; }
just link project but doesn't fail if there's no auth
just link project but doesn t fail if there s no auth