mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 00:28:22 +00:00
fix: [user] fix role edit
This commit is contained in:
parent
0a7a61e510
commit
09bd748253
3 changed files with 7 additions and 5 deletions
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
<div class="card-body">
|
||||
<p>User: {{new_user['email']}}</p>
|
||||
<p>Password: {{new_user['password']}}</p>
|
||||
<img src="data:image/png;base64, {{ qr_code }}">
|
||||
<a href="{{url_for('settings_b.users_list')}}" class="btn btn-primary"><i class="fas fa-eye-slash"></i> Hide</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue