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:
Andrew 2022-06-09 19:34:33 +00:00
commit ce8733a079
5 changed files with 34 additions and 37 deletions

View File

@ -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")

View File

@ -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")
),
"lang_page": self.helper.get_lang_page(self.helper.get_setting("language")),
"query": "",
}
except:
self.redirect("/public/login.html")
if self.request.query:
page_data["query"] = self.request.query

View File

@ -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,
)

View File

@ -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 () {

View File

@ -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
});