From 5d64f2606678cf0f87b1fbc69f07ec8a86929d95 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Tue, 6 Feb 2024 14:39:56 -0800 Subject: [PATCH] patch admin pwd update --- server/utils/helpers/admin/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/utils/helpers/admin/index.js b/server/utils/helpers/admin/index.js index 87a01278..c114417d 100644 --- a/server/utils/helpers/admin/index.js +++ b/server/utils/helpers/admin/index.js @@ -20,9 +20,13 @@ function validRoleSelection(currentUser = {}, newUserParams = {}) { // Check to make sure with this update that includes a role change to an existing admin to a non-admin // that we still have at least one admin left or else they will lock themselves out. async function canModifyAdmin(userToModify, updates) { - // if updates don't include role property or the user being modified isn't an admin currently - skip. + // if updates don't include role property + // or the user being modified isn't an admin currently + // or the updates role is equal to the users current role. + // skip validation. if (!updates.hasOwnProperty("role")) return { valid: true, error: null }; if (userToModify.role !== ROLES.admin) return { valid: true, error: null }; + if (updates.role === userToModify.role) return { valid: true, error: null }; const adminCount = await User.count({ role: ROLES.admin }); if (adminCount - 1 <= 0)