Allow update of default permission keys missing for user

This commit is contained in:
Nicholas Wallace 2024-09-02 10:28:03 -07:00
parent 9cca731acc
commit 790c1fb34a

View File

@ -270,8 +270,10 @@ class UserController {
const permissions = { const permissions = {
...user.permissions ...user.permissions
} }
const defaultPermissions = Database.userModel.getDefaultPermissionsForUserType(updatePayload.type || 'user')
for (const key in updatePayload.permissions) { for (const key in updatePayload.permissions) {
if (permissions[key] !== undefined) { // Check that the key is a valid permission key or is included in the default permissions
if (permissions[key] !== undefined || defaultPermissions[key] !== undefined) {
if (typeof updatePayload.permissions[key] !== 'boolean') { if (typeof updatePayload.permissions[key] !== 'boolean') {
Logger.warn(`[UserController] update: Invalid permission value for key ${key}. Should be boolean`) Logger.warn(`[UserController] update: Invalid permission value for key ${key}. Should be boolean`)
} else if (permissions[key] !== updatePayload.permissions[key]) { } else if (permissions[key] !== updatePayload.permissions[key]) {