mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-31 12:56:11 +01:00
Merge branch 'bug/pretzel-bug-cleanup' into 'dev'
Bug/pretzel bug cleanup See merge request crafty-controller/crafty-4!287
This commit is contained in:
commit
3c7c753baa
@ -18,6 +18,7 @@ from app.classes.controllers.roles_controller import RolesController
|
|||||||
from app.classes.controllers.server_perms_controller import ServerPermsController
|
from app.classes.controllers.server_perms_controller import ServerPermsController
|
||||||
from app.classes.controllers.servers_controller import ServersController
|
from app.classes.controllers.servers_controller import ServersController
|
||||||
from app.classes.models.server_permissions import EnumPermissionsServer
|
from app.classes.models.server_permissions import EnumPermissionsServer
|
||||||
|
from app.classes.shared.main_models import DatabaseShortcuts
|
||||||
from app.classes.models.users import HelperUsers
|
from app.classes.models.users import HelperUsers
|
||||||
from app.classes.models.roles import HelperRoles
|
from app.classes.models.roles import HelperRoles
|
||||||
from app.classes.models.management import HelpersManagement
|
from app.classes.models.management import HelpersManagement
|
||||||
@ -88,11 +89,24 @@ class Controller:
|
|||||||
server_path = os.path.join(full_temp, "server")
|
server_path = os.path.join(full_temp, "server")
|
||||||
os.mkdir(server_path)
|
os.mkdir(server_path)
|
||||||
if exec_user["superuser"]:
|
if exec_user["superuser"]:
|
||||||
auth_servers = self.servers.get_all_defined_servers()
|
defined_servers = self.servers.list_defined_servers()
|
||||||
|
user_servers = []
|
||||||
|
for server in defined_servers:
|
||||||
|
if server not in user_servers:
|
||||||
|
user_servers.append(
|
||||||
|
DatabaseShortcuts.get_data_obj(server.server_object)
|
||||||
|
)
|
||||||
|
auth_servers = user_servers
|
||||||
else:
|
else:
|
||||||
user_servers = self.servers.get_authorized_servers(
|
defined_servers = self.servers.get_authorized_servers(
|
||||||
int(exec_user["user_id"])
|
int(exec_user["user_id"])
|
||||||
)
|
)
|
||||||
|
user_servers = []
|
||||||
|
for server in defined_servers:
|
||||||
|
if server not in user_servers:
|
||||||
|
user_servers.append(
|
||||||
|
DatabaseShortcuts.get_data_obj(server.server_object)
|
||||||
|
)
|
||||||
auth_servers = []
|
auth_servers = []
|
||||||
for server in user_servers:
|
for server in user_servers:
|
||||||
if (
|
if (
|
||||||
|
@ -17,6 +17,8 @@ class DatabaseBuilder:
|
|||||||
logger.info("Fresh Install Detected - Creating Default Settings")
|
logger.info("Fresh Install Detected - Creating Default Settings")
|
||||||
Console.info("Fresh Install Detected - Creating Default Settings")
|
Console.info("Fresh Install Detected - Creating Default Settings")
|
||||||
default_data = self.helper.find_default_password()
|
default_data = self.helper.find_default_password()
|
||||||
|
# Reset this value if the DB has been dumped
|
||||||
|
self.helper.set_setting("apikey_secret", "random")
|
||||||
|
|
||||||
username = default_data.get("username", "admin")
|
username = default_data.get("username", "admin")
|
||||||
password = default_data.get("password", "crafty")
|
password = default_data.get("password", "crafty")
|
||||||
|
@ -398,6 +398,10 @@ class AjaxHandler(BaseHandler):
|
|||||||
self.controller.rename_backup_dir(
|
self.controller.rename_backup_dir(
|
||||||
server_id, new_server_id, new_server["server_uuid"]
|
server_id, new_server_id, new_server["server_uuid"]
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
|
self.tasks_manager.remove_all_server_tasks(server_id)
|
||||||
|
except:
|
||||||
|
logger.info("No active tasks found for server")
|
||||||
self.controller.remove_server(server_id, True)
|
self.controller.remove_server(server_id, True)
|
||||||
self.redirect("/panel/dashboard")
|
self.redirect("/panel/dashboard")
|
||||||
|
|
||||||
@ -416,6 +420,10 @@ class AjaxHandler(BaseHandler):
|
|||||||
self.controller.rename_backup_dir(
|
self.controller.rename_backup_dir(
|
||||||
server_id, new_server_id, new_server["server_uuid"]
|
server_id, new_server_id, new_server["server_uuid"]
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
|
self.tasks_manager.remove_all_server_tasks(server_id)
|
||||||
|
except:
|
||||||
|
logger.info("No active tasks found for server")
|
||||||
self.controller.remove_server(server_id, True)
|
self.controller.remove_server(server_id, True)
|
||||||
self.redirect("/panel/dashboard")
|
self.redirect("/panel/dashboard")
|
||||||
|
|
||||||
|
@ -1108,13 +1108,18 @@ class PanelHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
if exec_user["superuser"]:
|
if exec_user["superuser"]:
|
||||||
page_data[
|
defined_servers = self.controller.servers.list_defined_servers()
|
||||||
"servers_all"
|
|
||||||
] = self.controller.servers.get_all_defined_servers()
|
|
||||||
else:
|
else:
|
||||||
page_data[
|
defined_servers = self.controller.servers.get_authorized_servers(
|
||||||
"servers_all"
|
exec_user["user_id"]
|
||||||
] = self.controller.servers.get_authorized_servers(exec_user["user_id"])
|
)
|
||||||
|
page_servers = []
|
||||||
|
for server in defined_servers:
|
||||||
|
if server not in page_servers:
|
||||||
|
page_servers.append(
|
||||||
|
DatabaseShortcuts.get_data_obj(server.server_object)
|
||||||
|
)
|
||||||
|
page_data["servers_all"] = page_servers
|
||||||
page_data[
|
page_data[
|
||||||
"permissions_all"
|
"permissions_all"
|
||||||
] = self.controller.server_perms.list_defined_permissions()
|
] = self.controller.server_perms.list_defined_permissions()
|
||||||
@ -1127,13 +1132,18 @@ class PanelHandler(BaseHandler):
|
|||||||
role_id = self.get_argument("id", None)
|
role_id = self.get_argument("id", None)
|
||||||
page_data["role"] = self.controller.roles.get_role_with_servers(role_id)
|
page_data["role"] = self.controller.roles.get_role_with_servers(role_id)
|
||||||
if exec_user["superuser"]:
|
if exec_user["superuser"]:
|
||||||
page_data[
|
defined_servers = self.controller.servers.list_defined_servers()
|
||||||
"servers_all"
|
|
||||||
] = self.controller.servers.get_all_defined_servers()
|
|
||||||
else:
|
else:
|
||||||
page_data[
|
defined_servers = self.controller.servers.get_authorized_servers(
|
||||||
"servers_all"
|
exec_user["user_id"]
|
||||||
] = self.controller.servers.get_authorized_servers(exec_user["user_id"])
|
)
|
||||||
|
page_servers = []
|
||||||
|
for server in defined_servers:
|
||||||
|
if server not in page_servers:
|
||||||
|
page_servers.append(
|
||||||
|
DatabaseShortcuts.get_data_obj(server.server_object)
|
||||||
|
)
|
||||||
|
page_data["servers_all"] = page_servers
|
||||||
page_data[
|
page_data[
|
||||||
"permissions_all"
|
"permissions_all"
|
||||||
] = self.controller.server_perms.list_defined_permissions()
|
] = self.controller.server_perms.list_defined_permissions()
|
||||||
|
@ -236,7 +236,7 @@ class ServerHandler(BaseHandler):
|
|||||||
server_port = server_data.get("server_port")
|
server_port = server_data.get("server_port")
|
||||||
server_type = server_data.get("type")
|
server_type = server_data.get("type")
|
||||||
|
|
||||||
self.controller.servers.create_server(
|
new_server_id = self.controller.servers.create_server(
|
||||||
new_server_name,
|
new_server_name,
|
||||||
new_server_uuid,
|
new_server_uuid,
|
||||||
new_server_path,
|
new_server_path,
|
||||||
@ -248,6 +248,22 @@ class ServerHandler(BaseHandler):
|
|||||||
server_type,
|
server_type,
|
||||||
server_port,
|
server_port,
|
||||||
)
|
)
|
||||||
|
if not exec_user["superuser"]:
|
||||||
|
new_server_uuid = self.controller.servers.get_server_data_by_id(
|
||||||
|
new_server_id
|
||||||
|
).get("server_uuid")
|
||||||
|
role_id = self.controller.roles.add_role(
|
||||||
|
f"Creator of Server with uuid={new_server_uuid}"
|
||||||
|
)
|
||||||
|
self.controller.server_perms.add_role_server(
|
||||||
|
new_server_id, role_id, "11111111"
|
||||||
|
)
|
||||||
|
self.controller.users.add_role_to_user(
|
||||||
|
exec_user["user_id"], role_id
|
||||||
|
)
|
||||||
|
self.controller.crafty_perms.add_server_creation(
|
||||||
|
exec_user["user_id"]
|
||||||
|
)
|
||||||
|
|
||||||
self.controller.servers.init_all_servers()
|
self.controller.servers.init_all_servers()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user