From 09bd74825356c694b7fb91f14259f59d9935c5fc Mon Sep 17 00:00:00 2001 From: terrtia Date: Fri, 13 Sep 2024 11:00:30 +0200 Subject: [PATCH] fix: [user] fix role edit --- bin/lib/ail_users.py | 7 +++++-- var/www/blueprints/settings_b.py | 4 ++-- var/www/templates/settings/create_user.html | 1 - 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/lib/ail_users.py b/bin/lib/ail_users.py index c5bc4d93..7bdf5826 100755 --- a/bin/lib/ail_users.py +++ b/bin/lib/ail_users.py @@ -354,7 +354,7 @@ def create_user(user_id, password=None, admin_id=None, chg_passwd=True, org_uuid # TODO edit_org # TODO LOG -def edit_user(admin_id, user_id, password=None, chg_passwd=False, org_uuid=None, edit_otp=False, otp=True): +def edit_user(admin_id, user_id, password=None, chg_passwd=False, org_uuid=None, edit_otp=False, otp=True, role=None): if password: password_hash = hashing_password(password) if chg_passwd: @@ -374,6 +374,9 @@ def edit_user(admin_id, user_id, password=None, chg_passwd=False, org_uuid=None, current_org.remove_user(user_id) org.add_user(user_id) + if role: + set_user_role(user_id, role) + # 2FA OTP if edit_otp: if otp or is_2fa_enabled(): @@ -690,7 +693,7 @@ def api_create_user(admin_id, ip_address, user_agent, user_id, password, org_uui access_logger.info(f'Create user {user_id}', extra={'user_id': admin_id, 'ip_address': ip_address, 'user_agent': user_agent}) # Edit else: - edit_user(admin_id, user_id, password, chg_passwd=True, org_uuid=org_uuid, edit_otp=True, otp=otp) + edit_user(admin_id, user_id, password, chg_passwd=True, org_uuid=org_uuid, edit_otp=True, otp=otp, role=role) access_logger.info(f'Edit user {user_id}', extra={'user_id': admin_id, 'ip_address': ip_address, 'user_agent': user_agent}) def api_change_user_self_password(user_id, password): diff --git a/var/www/blueprints/settings_b.py b/var/www/blueprints/settings_b.py index 1d96bea2..5059df50 100644 --- a/var/www/blueprints/settings_b.py +++ b/var/www/blueprints/settings_b.py @@ -279,8 +279,8 @@ def create_user_post(): edit = False ail_users.api_create_user(admin_id, request.access_route[0], request.user_agent, email, password, org_uuid, role, enable_2_fa) new_user = {'email': email, 'password': str_password, 'org': org_uuid, 'otp': enable_2_fa, 'edited': edit} - qr_code = ail_users.create_qr_code(f'{email} - {password}') - return render_template("create_user.html", new_user=new_user, meta={}, qr_code=qr_code, + # qr_code = ail_users.create_qr_code(f'{email} - {password}') + return render_template("create_user.html", new_user=new_user, meta={}, all_roles=all_roles, acl_admin=True) else: diff --git a/var/www/templates/settings/create_user.html b/var/www/templates/settings/create_user.html index 89c5ec19..96ceea7b 100644 --- a/var/www/templates/settings/create_user.html +++ b/var/www/templates/settings/create_user.html @@ -39,7 +39,6 @@

User: {{new_user['email']}}

Password: {{new_user['password']}}

- Hide