Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const ResourceFactory = require('resourcejs');
const Resource = ResourceFactory.Resource;
const _ = require('lodash');
module.exports = function(router) {
const hook = require('../util/hook')(router.formio);
const handlers = router.formio.middleware.submissionHandler;
const hiddenFields = ['deleted', '__v', 'machineName'];
// Manually update the handlers, to add additional middleware.
handlers.beforePost = [
router.formio.middleware.filterIdCreate,
router.formio.middleware.permissionHandler,
router.formio.middleware.filterMongooseExists({field: 'deleted', isNull: true}),
router.formio.middleware.bootstrapEntityOwner,
router.formio.middleware.bootstrapSubmissionAccess,
router.formio.middleware.addSubmissionResourceAccess,
router.formio.middleware.condenseSubmissionPermissionTypes,