mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'dev' into 'master'
Fix user permissions/Fix occasional stack on login/Fix API Output Schema See merge request crafty-controller/crafty-4!305
This commit is contained in:
commit
385e991136
@ -139,15 +139,23 @@ class PermissionsCrafty:
|
||||
):
|
||||
# http://docs.peewee-orm.com/en/latest/peewee/querying.html#upsert
|
||||
|
||||
UserCrafty.replace(
|
||||
{
|
||||
UserCrafty.user_id: user_id,
|
||||
UserCrafty.permissions: permissions_mask,
|
||||
UserCrafty.limit_server_creation: limit_server_creation,
|
||||
UserCrafty.limit_user_creation: limit_user_creation,
|
||||
UserCrafty.limit_role_creation: limit_role_creation,
|
||||
}
|
||||
).execute()
|
||||
try:
|
||||
user_crafty = UserCrafty.select().where(UserCrafty.user_id == user_id).get()
|
||||
user_crafty.permissions = permissions_mask
|
||||
user_crafty.limit_server_creation = limit_server_creation
|
||||
user_crafty.limit_user_creation = limit_user_creation
|
||||
user_crafty.limit_role_creation = limit_role_creation
|
||||
UserCrafty.save(user_crafty)
|
||||
except:
|
||||
UserCrafty.insert(
|
||||
{
|
||||
UserCrafty.user_id: user_id,
|
||||
UserCrafty.permissions: permissions_mask,
|
||||
UserCrafty.limit_server_creation: limit_server_creation,
|
||||
UserCrafty.limit_user_creation: limit_user_creation,
|
||||
UserCrafty.limit_role_creation: limit_role_creation,
|
||||
}
|
||||
).execute()
|
||||
|
||||
@staticmethod
|
||||
def get_created_quantity_list(user_id):
|
||||
|
@ -1,6 +1,7 @@
|
||||
from contextlib import redirect_stderr
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import time
|
||||
import datetime
|
||||
import base64
|
||||
@ -842,7 +843,10 @@ class ServerInstance:
|
||||
args=[temp_dir + "/", backup_filename + ".zip"],
|
||||
)
|
||||
# pylint: disable=unexpected-keyword-arg
|
||||
FileHelpers.copy_dir(self.server_path, temp_dir, dirs_exist_ok=True)
|
||||
try:
|
||||
FileHelpers.copy_dir(self.server_path, temp_dir, dirs_exist_ok=True)
|
||||
except shutil.Error as e:
|
||||
logger.error(f"Failed to fully complete backup due to shutil error {e}")
|
||||
excluded_dirs = HelpersManagement.get_excluded_backup_dirs(self.server_id)
|
||||
server_dir = Helpers.get_os_understandable_path(self.settings["path"])
|
||||
|
||||
|
@ -17,6 +17,22 @@ bearer_pattern = re.compile(r"^Bearer ", flags=re.IGNORECASE)
|
||||
|
||||
|
||||
class BaseHandler(tornado.web.RequestHandler):
|
||||
nobleach = {bool, type(None)}
|
||||
redactables = ("pass", "api")
|
||||
|
||||
helper: Helpers
|
||||
controller: Controller
|
||||
translator: Translation
|
||||
|
||||
# noinspection PyAttributeOutsideInit
|
||||
def initialize(
|
||||
self, helper=None, controller=None, tasks_manager=None, translator=None
|
||||
):
|
||||
self.helper = helper
|
||||
self.controller = controller
|
||||
self.tasks_manager = tasks_manager
|
||||
self.translator = translator
|
||||
|
||||
def set_default_headers(self) -> None:
|
||||
"""
|
||||
Fix CORS
|
||||
@ -38,22 +54,6 @@ class BaseHandler(tornado.web.RequestHandler):
|
||||
self.set_status(204)
|
||||
self.finish()
|
||||
|
||||
nobleach = {bool, type(None)}
|
||||
redactables = ("pass", "api")
|
||||
|
||||
helper: Helpers
|
||||
controller: Controller
|
||||
translator: Translation
|
||||
|
||||
# noinspection PyAttributeOutsideInit
|
||||
def initialize(
|
||||
self, helper=None, controller=None, tasks_manager=None, translator=None
|
||||
):
|
||||
self.helper = helper
|
||||
self.controller = controller
|
||||
self.tasks_manager = tasks_manager
|
||||
self.translator = translator
|
||||
|
||||
def get_remote_ip(self):
|
||||
remote_ip = (
|
||||
self.request.headers.get("X-Real-IP")
|
||||
|
@ -32,18 +32,15 @@ class PublicHandler(BaseHandler):
|
||||
|
||||
error = bleach.clean(self.get_argument("error", "Invalid Login!"))
|
||||
error_msg = bleach.clean(self.get_argument("error_msg", ""))
|
||||
try:
|
||||
page_data = {
|
||||
"version": self.helper.get_version_string(),
|
||||
"error": error,
|
||||
"lang": self.helper.get_setting("language"),
|
||||
"lang_page": self.helper.get_lang_page(
|
||||
self.helper.get_setting("language")
|
||||
),
|
||||
"query": "",
|
||||
}
|
||||
except:
|
||||
self.redirect("/public/login.html")
|
||||
|
||||
page_data = {
|
||||
"version": self.helper.get_version_string(),
|
||||
"error": error,
|
||||
"lang": self.helper.get_setting("language"),
|
||||
"lang_page": self.helper.get_lang_page(self.helper.get_setting("language")),
|
||||
"query": "",
|
||||
}
|
||||
|
||||
if self.request.query:
|
||||
page_data["query"] = self.request.query
|
||||
|
||||
|
@ -43,11 +43,11 @@ class ApiJsonSchemaHandler(BaseApiHandler):
|
||||
{"status": "ok", "data": create_role_schema},
|
||||
)
|
||||
elif schema_name == "server_patch":
|
||||
self.finish_json(200, server_patch_schema)
|
||||
self.finish_json(200, {"status": "ok", "data": server_patch_schema})
|
||||
elif schema_name == "new_server":
|
||||
self.finish_json(
|
||||
200,
|
||||
new_server_schema,
|
||||
{"status": "ok", "data": new_server_schema},
|
||||
)
|
||||
elif schema_name == "user_patch":
|
||||
self.finish_json(
|
||||
|
@ -179,7 +179,7 @@ class Webserver:
|
||||
xsrf_cookies=True,
|
||||
autoreload=False,
|
||||
log_function=self.log_function,
|
||||
login_url="/login",
|
||||
login_url="/public/login",
|
||||
default_handler_class=PublicHandler,
|
||||
static_handler_class=CustomStaticHandler,
|
||||
serve_traceback=debug_errors,
|
||||
@ -205,7 +205,7 @@ class Webserver:
|
||||
autoreload=False,
|
||||
log_function=self.log_function,
|
||||
default_handler_class=HTTPHandler,
|
||||
login_url="/login",
|
||||
login_url="/public/login",
|
||||
serve_traceback=debug_errors,
|
||||
)
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
<link rel="stylesheet" href="/static/assets/vendors/typicons/typicons.css">
|
||||
<link rel="stylesheet" href="/static/assets/vendors/fontawesome5/css/all.css">
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.css" />
|
||||
href="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.css" />
|
||||
<link rel="stylesheet" href="/static/assets/vendors/css/vendor.bundle.base.css">
|
||||
<link rel="stylesheet" href="/static/assets/css/crafty.css">
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
{% include notify.html %}
|
||||
|
||||
<button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button"
|
||||
data-toggle="offcanvas">
|
||||
data-toggle="offcanvas">
|
||||
<span class="mdi mdi-menu"></span>
|
||||
</button>
|
||||
</div>
|
||||
@ -158,7 +158,7 @@
|
||||
<script src="/static/assets/js/shared/hoverable-collapse.js"></script>
|
||||
<script src="/static/assets/js/shared/misc.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.js"></script>
|
||||
src="https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/5.4.0/bootbox.min.js"></script>
|
||||
<script type="text/javascript" src="/static/assets/js/motd.js"></script>
|
||||
|
||||
@ -315,8 +315,8 @@
|
||||
x.remove()
|
||||
}
|
||||
bootbox.confirm({
|
||||
title: '{% raw translate("error", "eulaTitle", data['lang']) %}',
|
||||
message: '{% raw translate("error", "eulaMsg", data['lang']) %} <br><br><a href="https://account.mojang.com/documents/minecraft_eula" target="_blank">EULA</a><br><br>{% raw translate("error", "eulaAgree", data['lang']) %}',
|
||||
title: "{% raw translate('error', 'eulaTitle', data['lang']) %}",
|
||||
message: "{% raw translate('error', 'eulaMsg', data['lang']) %} <br><br><a href='https://account.mojang.com/documents/minecraft_eula' target='_blank'>EULA</a><br><br>{% raw translate('error', 'eulaAgree', data['lang']) %}",
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'Yes',
|
||||
@ -450,7 +450,7 @@
|
||||
console.log('%c[Crafty Controller] %cReady for JS!', 'font-weight: 900; color: #800080;', 'font-weight: 900; color: #eee;');
|
||||
$('#support_logs').click(function () {
|
||||
var dialog = bootbox.dialog({
|
||||
message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i>{{ translate('notify', 'preparingLogs', data['lang']) }}</p>',
|
||||
message: "<p class='text- center mb - 0'><i class='fa fa - spin fa - cog'></i>{{ translate('notify', 'preparingLogs', data['lang']) }}</p>",
|
||||
closeButton: false
|
||||
});
|
||||
setTimeout(function () {
|
||||
|
@ -283,7 +283,7 @@
|
||||
function restore_backup(filename, id) {
|
||||
var token = getCookie("_xsrf")
|
||||
var dialog = bootbox.dialog({
|
||||
message: '<i class="fa fa-spin fa-spinner"></i> {{ translate('serverBackups', 'restoring', data['lang']) }}',
|
||||
message: "<i class='fa fa-spin fa-spinner'></i> {{ translate('serverBackups', 'restoring', data['lang']) }}",
|
||||
closeButton: false
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user