Merge branch 'pretzel-branch' into 'dev'

Fix user error when trying to edit own language

See merge request crafty-controller/crafty-commander!123
This commit is contained in:
Andrew 2021-12-21 20:59:33 +00:00
commit b3cb6006e9
4 changed files with 16 additions and 9 deletions

View File

@ -165,7 +165,10 @@ class Permissions_Servers:
else: else:
roles_list = users_helper.get_user_roles_id(user_id) 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() 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) permissions_list = server_permissions.get_permissions(permissions_mask)
return permissions_list return permissions_list

View File

@ -97,12 +97,16 @@ class Helpers:
@staticmethod @staticmethod
def check_port(server_port): def check_port(server_port):
try: a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host_public = get('https://api.ipify.org').text
tn = telnetlib.Telnet(host_public, server_port, 10) ip = get('https://api.ipify.org').content.decode('utf8')
telnetlib.close()
location = (ip, server_port)
result_of_check = a_socket.connect_ex(location)
if result_of_check == 0:
return True return True
except Exception as err: else:
return False return False
@staticmethod @staticmethod

View File

@ -73,7 +73,6 @@ class TasksManager:
logger.info("Loading schedule ID#{i}: '{a}' every {n} {t} at {s}".format( logger.info("Loading schedule ID#{i}: '{a}' every {n} {t} at {s}".format(
i=j.schedule_id, a=j.action, n=j.interval, t=j.interval_type, s=j.start_time)) i=j.schedule_id, a=j.action, n=j.interval, t=j.interval_type, s=j.start_time))
try: try:
print(self.controller.users.get_id_by_name('system'))
getattr(schedule.every(j.interval), j.interval_type).at(j.start_time).do( getattr(schedule.every(j.interval), j.interval_type).at(j.start_time).do(
self.controller.management.send_command, self.controller.users.get_id_by_name('system'), j.server_id, "127.27.23.89", j.action) self.controller.management.send_command, self.controller.users.get_id_by_name('system'), j.server_id, "127.27.23.89", j.action)
except schedule.ScheduleValueError as e: except schedule.ScheduleValueError as e:

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['quantity_server'] = self.controller.crafty_perms.list_crafty_permissions_quantity_limits(user_id)
page_data['languages'] = [] page_data['languages'] = []
page_data['languages'].append(self.controller.users.get_user_lang_by_id(user_id)) 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.endswith('.json'):
if file != str(page_data['languages'][0] + '.json'): if file != str(page_data['languages'][0] + '.json'):
page_data['languages'].append(file.split('.')[0]) page_data['languages'].append(file.split('.')[0])
@ -916,8 +916,9 @@ class PanelHandler(BaseHandler):
elif page == "add_user": 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.") 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)) username = bleach.clean(self.get_argument('username', None))
password0 = bleach.clean(self.get_argument('password0', None)) password0 = bleach.clean(self.get_argument('password0', None))
password1 = bleach.clean(self.get_argument('password1', None)) password1 = bleach.clean(self.get_argument('password1', None))