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:
Akshay Joshi 2022-08-16 17:28:45 +05:30
parent d45072fae5
commit ef91207669
3 changed files with 22 additions and 9 deletions

View File

@ -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>
);

View File

@ -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))

View File

@ -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)) {