mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-27 00:36:52 -06:00
1) Fixed an issue where an existing user is deleted and recreated again in the User Management dialog. Fixes #7618
2) Fixed preferences issue when changing themes. 3) Added validation for user names that already exist.
This commit is contained in:
parent
d45072fae5
commit
ef91207669
@ -131,8 +131,8 @@ export default function ModalProvider({ children }) {
|
||||
return (
|
||||
<ModalContext.Provider value={modalContext}>
|
||||
{children}
|
||||
{modals.map((modalOptions, i) => (
|
||||
<ModalContainer key={i} {...modalOptions} />
|
||||
{modals.map((modalOptions) => (
|
||||
<ModalContainer key={modalOptions.id} {...modalOptions} />
|
||||
))}
|
||||
</ModalContext.Provider>
|
||||
);
|
||||
|
@ -400,6 +400,12 @@ def save():
|
||||
)
|
||||
|
||||
try:
|
||||
# Delete Users
|
||||
if 'deleted' in data:
|
||||
for item in data['deleted']:
|
||||
status, res = delete_user(item['id'])
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
# Create Users
|
||||
if 'added' in data:
|
||||
for item in data['added']:
|
||||
@ -412,13 +418,6 @@ def save():
|
||||
status, res = update_user(item['id'], item)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
# Delete Users
|
||||
if 'deleted' in data:
|
||||
for item in data['deleted']:
|
||||
status, res = delete_user(item['id'])
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
@ -149,6 +149,20 @@ class UserManagementCollection extends BaseUISchema {
|
||||
setError('username', null);
|
||||
}
|
||||
|
||||
if (state.auth_source != authConstant['INTERNAL']) {
|
||||
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 &&
|
||||
obj.top._sessData.userManagement[i].username == state.username &&
|
||||
obj.top._sessData.userManagement[i].auth_source == state.auth_source) {
|
||||
msg = gettext('User name \'%s\' already exists', state.username);
|
||||
setError('username', msg);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state.auth_source == authConstant['INTERNAL']) {
|
||||
let email_filter = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
||||
if (isEmptyString(state.email)) {
|
||||
|
Loading…
Reference in New Issue
Block a user