Fix user error when trying to edit own language

Fix bug where users could not be created because of a bad logical check for system uesr.
This commit is contained in:
Andrew 2021-12-21 15:39:33 -05:00
parent 2afecf8fab
commit 8a2f938dc9
2 changed files with 7 additions and 3 deletions

View File

@ -165,7 +165,10 @@ class Permissions_Servers:
else:
roles_list = users_helper.get_user_roles_id(user_id)
role_server = Role_Servers.select().where(Role_Servers.role_id.in_(roles_list)).where(Role_Servers.server_id == int(server_id)).execute()
permissions_mask = role_server[0].permissions
if len(role_server) > 0:
permissions_mask = role_server[0].permissions
else:
permissions_mask = '00000000'
permissions_list = server_permissions.get_permissions(permissions_mask)
return permissions_list

View File

@ -469,7 +469,7 @@ class PanelHandler(BaseHandler):
page_data['quantity_server'] = self.controller.crafty_perms.list_crafty_permissions_quantity_limits(user_id)
page_data['languages'] = []
page_data['languages'].append(self.controller.users.get_user_lang_by_id(user_id))
for file in os.listdir(os.path.join(helper.root_dir, 'app', 'translations')):
for file in sorted(os.listdir(os.path.join(helper.root_dir, 'app', 'translations'))):
if file.endswith('.json'):
if file != str(page_data['languages'][0] + '.json'):
page_data['languages'].append(file.split('.')[0])
@ -916,8 +916,9 @@ class PanelHandler(BaseHandler):
elif page == "add_user":
if bleach.clean(self.get_argument('username', None)):
if bleach.clean(self.get_argument('username', None)).lower() == 'system':
self.redirect("/panel/error?error=Unauthorized access: username system is reserved for the Crafty system. Please choose a different username.")
return
username = bleach.clean(self.get_argument('username', None))
password0 = bleach.clean(self.get_argument('password0', None))
password1 = bleach.clean(self.get_argument('password1', None))