Skip to content

Commit

Permalink
Fix: Extend Form Submitter permissions for GET /documentTemplates (bc…
Browse files Browse the repository at this point in the history
…gov#1493)

* removed template read permissions

* migration to extend form submitter role

* update form_submitter permission
  • Loading branch information
vijaivir authored Sep 5, 2024
1 parent d655b0d commit 14380e4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions app/src/db/migrations/20240904140843_047-extend-submitter-role.js
Original file line number Diff line number Diff line change
@@ -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<void> }
*/
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<void> }
*/
exports.down = function(knex) {
return Promise.resolve().then(() =>
knex('role_permission')
.where({
createdBy: CREATED_BY,
})
.del()
);
};
2 changes: 1 addition & 1 deletion app/src/forms/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 14380e4

Please sign in to comment.