lib/middleware/forms.js
function checkFormAssociation(req, res, next){
  var requestedFormId = req.params.id;
  req.appformsResultPayload = req.appformsResultPayload || {};
  var formsAssociatedWithProject = req.appformsResultPayload.data || [];

  var foundForm = _.find(formsAssociatedWithProject, function(formId){
    return requestedFormId === formId;
  });

  //Form Associated, can get the form
  if(foundForm){
    return next();
  }  else{
    return next(new Error("Invalid Form Request. Form Not Associated With The Project"));
  }
}
function checkFormAssociation(req, res, next){
  var requestedFormId = req.params.id;
  req.appformsResultPayload = req.appformsResultPayload || {};
  var formsAssociatedWithProject = req.appformsResultPayload.data || [];

  var foundForm = _.find(formsAssociatedWithProject, function(formId){
    return requestedFormId === formId;
  });

  //Form Associated, can get the form
  if(foundForm){
    return next();
  }  else{
    return next(new Error("Invalid Form Request. Form Not Associated With The Project"));
  }
}
function checkFormAssociation ( req , res , next ) { var requestedFormId = req . params . id ; req . appformsResultPayload = req . appformsResultPayload || { } ; var formsAssociatedWithProject = req . appformsResultPayload . data || [ ] ; var foundForm = _ . find ( formsAssociatedWithProject , function ( formId ) { return requestedFormId === formId ; } ) ; //Form Associated, can get the form if ( foundForm ) { return next ( ) ; } else { return next ( new Error ( "Invalid Form Request. Form Not Associated With The Project" ) ) ; } }
Middleware To Check That A Requested Form Exists
@param req
@param res
@param next
Middleware To Check That A Requested Form Exists