app.js
/**
 * Grants access to comment owner
 * or post owner that comment belongs to.
 */
Grants access to comment owner
or post owner that comment belongs to.
Grants access to comment owner or post owner that comment belongs to .
function commentOwner(req, res, next) {
  var conditions = {
    _id: req.params.commentId,
    _owner: req.session.user._id
  };
  Comment.count(conditions, function (err, count) {
    if (err) return next(err);
    if (count) return next();
    conditions = {
      comments: { $in : [req.params.commentId] },
      _owner: req.session.user._id
    };
    Post.count(conditions, function (err, count) {
      if (err) return next(err);
      return !!count ? next() : next(new HttpError(403));
    });
  });
}
function commentOwner ( req , res , next ) { var conditions = { _id : req . params . commentId , _owner : req . session . user . _id } ; Comment . count ( conditions , function ( err , count ) { if ( err ) return next ( err ) ; if ( count ) return next ( ) ; conditions = { comments : { $in : [ req . params . commentId ] } , _owner : req . session . user . _id } ; Post . count ( conditions , function ( err , count ) { if ( err ) return next ( err ) ; return ! ! count ? next ( ) : next ( new HttpError ( 403 ) ) ; } ) ; } ) ; }
Grants access to comment owner
 or post owner that comment belongs to.
Grants access to comment owner or post owner that comment belongs to .
// comment owner // post owner that this comment belongs to