From 9cca731acc004fda1a54093affb52effe3a249ee Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Mon, 2 Sep 2024 10:08:17 -0700 Subject: [PATCH 1/3] Add: missing default user permission property --- server/models/User.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/models/User.js b/server/models/User.js index 123d8fdf..2dd02b68 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -108,6 +108,7 @@ class User extends Model { accessAllLibraries: true, accessAllTags: true, accessExplicitContent: true, + selectedTagsNotAccessible: false, librariesAccessible: [], itemTagsSelected: [] } From 790c1fb34a6a8cba2d9be3084a3d05db6504a53d Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Mon, 2 Sep 2024 10:28:03 -0700 Subject: [PATCH 2/3] Allow update of default permission keys missing for user --- server/controllers/UserController.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/controllers/UserController.js b/server/controllers/UserController.js index d1b93695..6ef698e9 100644 --- a/server/controllers/UserController.js +++ b/server/controllers/UserController.js @@ -270,8 +270,10 @@ class UserController { const permissions = { ...user.permissions } + const defaultPermissions = Database.userModel.getDefaultPermissionsForUserType(updatePayload.type || 'user') 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') { Logger.warn(`[UserController] update: Invalid permission value for key ${key}. Should be boolean`) } else if (permissions[key] !== updatePayload.permissions[key]) { From 47712e63f1c52bd4c8d3940b9afb2eadb2bbddf4 Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 2 Sep 2024 15:55:25 -0500 Subject: [PATCH 3/3] Update user default permissions --- server/controllers/UserController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/UserController.js b/server/controllers/UserController.js index 6ef698e9..46ba943e 100644 --- a/server/controllers/UserController.js +++ b/server/controllers/UserController.js @@ -270,7 +270,7 @@ class UserController { const permissions = { ...user.permissions } - const defaultPermissions = Database.userModel.getDefaultPermissionsForUserType(updatePayload.type || 'user') + const defaultPermissions = Database.userModel.getDefaultPermissionsForUserType(updatePayload.type || user.type || 'user') for (const key in updatePayload.permissions) { // Check that the key is a valid permission key or is included in the default permissions if (permissions[key] !== undefined || defaultPermissions[key] !== undefined) {