mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'dev-FixingRedirectWithLoginPage' into 'dev'
Fixing Stack when redirected from Unauthorized page See merge request crafty-controller/crafty-4!304
This commit is contained in:
commit
ce8733a079
@ -17,6 +17,22 @@ bearer_pattern = re.compile(r"^Bearer ", flags=re.IGNORECASE)
|
|||||||
|
|
||||||
|
|
||||||
class BaseHandler(tornado.web.RequestHandler):
|
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:
|
def set_default_headers(self) -> None:
|
||||||
"""
|
"""
|
||||||
Fix CORS
|
Fix CORS
|
||||||
@ -38,22 +54,6 @@ class BaseHandler(tornado.web.RequestHandler):
|
|||||||
self.set_status(204)
|
self.set_status(204)
|
||||||
self.finish()
|
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):
|
def get_remote_ip(self):
|
||||||
remote_ip = (
|
remote_ip = (
|
||||||
self.request.headers.get("X-Real-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 = bleach.clean(self.get_argument("error", "Invalid Login!"))
|
||||||
error_msg = bleach.clean(self.get_argument("error_msg", ""))
|
error_msg = bleach.clean(self.get_argument("error_msg", ""))
|
||||||
try:
|
|
||||||
page_data = {
|
page_data = {
|
||||||
"version": self.helper.get_version_string(),
|
"version": self.helper.get_version_string(),
|
||||||
"error": error,
|
"error": error,
|
||||||
"lang": self.helper.get_setting("language"),
|
"lang": self.helper.get_setting("language"),
|
||||||
"lang_page": self.helper.get_lang_page(
|
"lang_page": self.helper.get_lang_page(self.helper.get_setting("language")),
|
||||||
self.helper.get_setting("language")
|
|
||||||
),
|
|
||||||
"query": "",
|
"query": "",
|
||||||
}
|
}
|
||||||
except:
|
|
||||||
self.redirect("/public/login.html")
|
|
||||||
if self.request.query:
|
if self.request.query:
|
||||||
page_data["query"] = self.request.query
|
page_data["query"] = self.request.query
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ class Webserver:
|
|||||||
xsrf_cookies=True,
|
xsrf_cookies=True,
|
||||||
autoreload=False,
|
autoreload=False,
|
||||||
log_function=self.log_function,
|
log_function=self.log_function,
|
||||||
login_url="/login",
|
login_url="/public/login",
|
||||||
default_handler_class=PublicHandler,
|
default_handler_class=PublicHandler,
|
||||||
static_handler_class=CustomStaticHandler,
|
static_handler_class=CustomStaticHandler,
|
||||||
serve_traceback=debug_errors,
|
serve_traceback=debug_errors,
|
||||||
@ -205,7 +205,7 @@ class Webserver:
|
|||||||
autoreload=False,
|
autoreload=False,
|
||||||
log_function=self.log_function,
|
log_function=self.log_function,
|
||||||
default_handler_class=HTTPHandler,
|
default_handler_class=HTTPHandler,
|
||||||
login_url="/login",
|
login_url="/public/login",
|
||||||
serve_traceback=debug_errors,
|
serve_traceback=debug_errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -315,8 +315,8 @@
|
|||||||
x.remove()
|
x.remove()
|
||||||
}
|
}
|
||||||
bootbox.confirm({
|
bootbox.confirm({
|
||||||
title: '{% raw translate("error", "eulaTitle", 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']) %}',
|
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: {
|
buttons: {
|
||||||
confirm: {
|
confirm: {
|
||||||
label: 'Yes',
|
label: 'Yes',
|
||||||
@ -450,7 +450,7 @@
|
|||||||
console.log('%c[Crafty Controller] %cReady for JS!', 'font-weight: 900; color: #800080;', 'font-weight: 900; color: #eee;');
|
console.log('%c[Crafty Controller] %cReady for JS!', 'font-weight: 900; color: #800080;', 'font-weight: 900; color: #eee;');
|
||||||
$('#support_logs').click(function () {
|
$('#support_logs').click(function () {
|
||||||
var dialog = bootbox.dialog({
|
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
|
closeButton: false
|
||||||
});
|
});
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
@ -283,7 +283,7 @@
|
|||||||
function restore_backup(filename, id) {
|
function restore_backup(filename, id) {
|
||||||
var token = getCookie("_xsrf")
|
var token = getCookie("_xsrf")
|
||||||
var dialog = bootbox.dialog({
|
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
|
closeButton: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user