diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c70b912..8bf1ed17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ TBD ### Bug fixes - Fix Bedrock cert issues ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/719)) - Make sure default.json is read from correct location ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/714)) +- Do not allow users at server limit to clone servers ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/718)) ### Tweaks - Bump pyOpenSSL & cryptography for CVE-2024-0727, CVE-2023-50782 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/716)) ### Lang diff --git a/app/classes/web/routes/api/servers/server/action.py b/app/classes/web/routes/api/servers/server/action.py index 153b889d..a30ab410 100644 --- a/app/classes/web/routes/api/servers/server/action.py +++ b/app/classes/web/routes/api/servers/server/action.py @@ -30,7 +30,15 @@ class ApiServersServerActionHandler(BaseApiHandler): return self.finish_json(400, {"status": "error", "error": "NOT_AUTHORIZED"}) if action == "clone_server": - return self._clone_server(server_id, auth_data[4]["user_id"]) + if ( + self.controller.crafty_perms.can_create_server(auth_data[4]["user_id"]) + or auth_data[4]["superuser"] + ): + self._clone_server(server_id, auth_data[4]["user_id"]) + return self.finish_json(200, {"status": "ok"}) + return self.finish_json( + 200, {"status": "error", "error": "SERVER_LIMIT_REACHED"} + ) if action == "eula": return self._agree_eula(server_id, auth_data[4]["user_id"]) @@ -94,6 +102,13 @@ class ApiServersServerActionHandler(BaseApiHandler): user_id, server_data.get("server_port"), ) + for role in self.controller.server_perms.get_server_roles(server_id): + mask = self.controller.server_perms.get_permissions_mask( + role.role_id, server_id + ) + self.controller.server_perms.add_role_server( + new_server_id, role.role_id, mask + ) self.controller.servers.init_all_servers() diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index 0d4fc0ac..e5cc46d4 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -598,26 +598,30 @@