From e40e91cf40e9a7b944f32db310a8c0ee9f676e97 Mon Sep 17 00:00:00 2001 From: Nathan Hoffman Date: Sun, 3 Sep 2023 13:51:44 -0700 Subject: [PATCH] Revert "Revert "new perms and no removing PMP perms on startup"" This reverts commit 97f97b6639348dabb6993c8226cf4bfee669b8a1. --- src/utilities/createInitialPermissions.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/utilities/createInitialPermissions.js b/src/utilities/createInitialPermissions.js index 9ac0f12b0..ffc655b60 100644 --- a/src/utilities/createInitialPermissions.js +++ b/src/utilities/createInitialPermissions.js @@ -72,7 +72,10 @@ const permissionsRoles = [ }, { roleName: 'Volunteer', - permissions: ['getReporteesLimitRoles'], + permissions: [ + 'getReporteesLimitRoles', + 'suggestTask', + ], }, { roleName: 'Core Team', @@ -105,7 +108,8 @@ const permissionsRoles = [ 'putUserProfile', 'infringementAuthorizer', 'getReporteesLimitRoles', - 'suggestTask', + 'updateTask', + 'putTeam', 'getAllInvInProjectWBS', 'postInvInProjectWBS', 'getAllInvInProject', @@ -239,12 +243,16 @@ const createInitialPermissions = async () => { role.permissions = permissions; role.save(); - // If role exists in db and is not updated, update it - } else if (!roleDataBase.permissions.every(perm => permissions.includes(perm)) || !permissions.every(perm => roleDataBase.permissions.includes(perm))) { + // If role exists in db and does not have every permission, add the missing permissions + } else if (!permissions.every(perm => roleDataBase.permissions.includes(perm))) { const roleId = roleDataBase._id; promises.push(Role.findById(roleId, (_, record) => { - record.permissions = permissions; + permissions.forEach((perm) => { + if (!record.permissions.includes(perm)) { + record.permissions.push(perm); + } + }); record.save(); })); }