diff --git a/app/src/db/migrations/20240904140843_047-extend-submitter-role.js b/app/src/db/migrations/20240904140843_047-extend-submitter-role.js new file mode 100644 index 000000000..c5519b811 --- /dev/null +++ b/app/src/db/migrations/20240904140843_047-extend-submitter-role.js @@ -0,0 +1,34 @@ +const uuid = require('uuid'); + +const { Permissions, Roles } = require('../../forms/common/constants'); + +const CREATED_BY = 'migration-047'; +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.up = function(knex) { + return Promise.resolve().then(() => { + const rolePermission = { + id: uuid.v4(), + createdBy: CREATED_BY, + role: Roles.FORM_SUBMITTER, + permission: Permissions.DOCUMENT_TEMPLATE_READ, + }; + return knex('role_permission').insert(rolePermission); + }); +}; + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.down = function(knex) { + return Promise.resolve().then(() => + knex('role_permission') + .where({ + createdBy: CREATED_BY, + }) + .del() + ); +}; diff --git a/app/src/forms/common/constants.js b/app/src/forms/common/constants.js index 7d377bedf..6cd51fbf9 100644 --- a/app/src/forms/common/constants.js +++ b/app/src/forms/common/constants.js @@ -29,7 +29,7 @@ module.exports = Object.freeze({ FORM_API_UPDATE: 'form_api_update', FORM_DELETE: 'form_delete', FORM_READ: 'form_read', - FORM_SUBMITTER: ['form_read', 'submission_create'], + FORM_SUBMITTER: ['form_read', 'submission_create', 'document_template_read'], FORM_UPDATE: 'form_update', SUBMISSION_CREATE: 'submission_create', SUBMISSION_DELETE: 'submission_delete',