Browse Source

v6.3.13.0

Changelog: https://roxy-wi.org/changelog#6_3_13
pull/364/head
Aidaho 1 year ago
parent
commit
c0f10dbc1f
  1. 14
      app/modules/db/sql.py
  2. 7
      app/modules/roxywi/user.py
  3. 5
      app/options.py

14
app/modules/db/sql.py

@ -4242,3 +4242,17 @@ def get_role_id(user_id: int, group_id: int) -> int:
out_error(e)
else:
return int(role_id.user_role_id)
def is_user_super_admin(user_id: int) -> bool:
query = UserGroups.select().where(UserGroups.user_id == user_id)
try:
query_res = query.execute()
except Exception as e:
out_error(e)
else:
for i in query_res:
if i.user_role_id == 1:
return True
else:
return False

7
app/modules/roxywi/user.py

@ -48,9 +48,10 @@ def create_user(new_user: str, email: str, password: str, role: str, activeuser:
def delete_user():
userdel = int(form.getvalue('userdel'))
count_super_admin_users = sql.get_super_admin_count()
if count_super_admin_users < 2:
raise Exception('error: you cannot delete a last user with superAdmin role')
if sql.is_user_super_admin(userdel):
count_super_admin_users = sql.get_super_admin_count()
if count_super_admin_users < 2:
raise Exception('error: you cannot delete a last user with superAdmin role')
user = sql.select_users(id=userdel)
username = ''
for u in user:

5
app/options.py

@ -756,7 +756,10 @@ if form.getvalue('newuser') is not None:
if form.getvalue('userdel') is not None:
import modules.roxywi.user as roxywi_user
roxywi_user.delete_user()
try:
roxywi_user.delete_user()
except Exception as e:
print(e)
if form.getvalue('updateuser') is not None:
import modules.roxywi.user as roxywi_user

Loading…
Cancel
Save