From 485265979e2b14990d808212693554e8a18b66f0 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Tue, 16 Aug 2022 15:25:25 +0530 Subject: [PATCH] Fixed an issue email already exists and disable the 'Locked' switch when its value is false. Fixes #7618 --- .../static/js/UserManagementDialog.jsx | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx b/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx index 9da39cf34..b07559eb4 100644 --- a/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx +++ b/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx @@ -33,6 +33,7 @@ class UserManagementCollection extends BaseUISchema { role: '2', newPassword: undefined, confirmPassword: undefined, + locked: false, auth_source: authConstant['INTERNAL'] }); @@ -131,7 +132,7 @@ class UserManagementCollection extends BaseUISchema { }, { id: 'locked', label: gettext('Locked'), cell: 'switch', width: 60, disableResizing: true, editable: (state)=> { - return obj.isEditable(state); + return state.locked; } } ]; @@ -162,10 +163,9 @@ class UserManagementCollection extends BaseUISchema { setError('email', null); } - let isEmailFound = false; - if (obj.top?._sessData?.userManagement) { + if (obj.isNew(state) && obj.top?._sessData?.userManagement) { for (let i=0; i < obj.top._sessData.userManagement.length; i++) { - if (obj.top._sessData.userManagement[i]?.id && + if (obj.top._sessData.userManagement[i]?.id && obj.top._sessData.userManagement[i].email == state.email) { msg = gettext('Email address \'%s\' already exists', state.email); setError('email', msg); @@ -174,12 +174,6 @@ class UserManagementCollection extends BaseUISchema { } } - if (obj.isNew(state) && isEmailFound) { - msg = gettext('Email address \'%s\' already exists', state.email); - setError('email', msg); - return true; - } - if (obj.isNew(state) && isEmptyString(state.newPassword)) { msg = gettext('Password cannot be empty for user %s', state.email); setError('newPassword', msg);