app.js
/**
 * Grants access to post owner.
 */
Grants access to post owner.
Grants access to post owner .
function postOwner(req, res, next) {
  var conditions = {
    titleUrl: req.params.postTitle,
    _owner: req.session.user._id
  };
  if ('undefined' !== typeof req.params.postId) {
    conditions = {
      _id: req.params.postId,
      _owner: req.session.user._id
    };
  }
  Post.count(conditions, function (err, count) {
    if (err) return next(err);
    return count === 1 ? next() : next(new HttpError(403));
  });
}
function postOwner ( req , res , next ) { var conditions = { titleUrl : req . params . postTitle , _owner : req . session . user . _id } ; if ( 'undefined' !== typeof req . params . postId ) { conditions = { _id : req . params . postId , _owner : req . session . user . _id } ; } Post . count ( conditions , function ( err , count ) { if ( err ) return next ( err ) ; return count === 1 ? next ( ) : next ( new HttpError ( 403 ) ) ; } ) ; }
Grants access to post owner.
Grants access to post owner .