mirror of
https://github.com/pretix/pretix.git
synced 2026-08-17 11:56:27 +00:00
Improve handling of logout during asynchronous tasks (Z#23238978) (#6341)
* Handle logout during async task requests properly * Handle fragments safely on webcheckin logout * Remove unnecessary comment * Revert hash change
This commit is contained in:
@@ -113,6 +113,10 @@ function async_task_check_error(jqXHR, textStatus, errorThrown) {
|
||||
"use strict";
|
||||
var respdom = $(jqXHR.responseText);
|
||||
var c = respdom.filter('.container');
|
||||
if (jqXHR.status === 401 && jqXHR.getResponseHeader("X-Login-Url")) {
|
||||
window.location = jqXHR.getResponseHeader("X-Login-Url") + "?next=" + encodeURIComponent(location.pathname + location.search + location.hash);
|
||||
return;
|
||||
}
|
||||
if (respdom.filter('form') && (respdom.filter('.has-error') || respdom.filter('.alert-danger'))) {
|
||||
// This is a failed form validation, let's just use it
|
||||
$("body").data('ajaxing', false);
|
||||
@@ -167,6 +171,10 @@ function async_task_callback(data, jqXHR, status) {
|
||||
function async_task_error(jqXHR, textStatus, errorThrown) {
|
||||
"use strict";
|
||||
$("body").data('ajaxing', false);
|
||||
if (jqXHR.status === 401 && jqXHR.getResponseHeader("X-Login-Url")) {
|
||||
window.location = jqXHR.getResponseHeader("X-Login-Url") + "?next=" + encodeURIComponent(location.pathname + location.search + location.hash);
|
||||
return;
|
||||
}
|
||||
waitingDialog.hide();
|
||||
if (textStatus === "timeout") {
|
||||
alert(gettext("The request took too long. Please try again."));
|
||||
|
||||
@@ -58,13 +58,14 @@ var i18nToString = function (i18nstring) {
|
||||
};
|
||||
|
||||
$(document).ajaxError(function (event, jqXHR, settings, thrownError) {
|
||||
waitingDialog.hide();
|
||||
var c = $(jqXHR.responseText).filter('.container');
|
||||
if (jqXHR.responseText && jqXHR.responseText.indexOf("<!-- pretix-login-marker -->") !== -1) {
|
||||
location.href = '/control/login?next=' + encodeURIComponent(location.pathname + location.search + location.hash)
|
||||
if (jqXHR.status === 401 && jqXHR.getResponseHeader("X-Login-Url")) {
|
||||
window.location = jqXHR.getResponseHeader("X-Login-Url") + "?next=" + encodeURIComponent(location.pathname + location.search + location.hash);
|
||||
} else if (c.length > 0) {
|
||||
waitingDialog.hide();
|
||||
ajaxErrDialog.show(c.first().html());
|
||||
} else if (thrownError !== "abort" && thrownError !== "") {
|
||||
waitingDialog.hide();
|
||||
console.error(event, jqXHR, settings, thrownError);
|
||||
alert(gettext('Unknown error.'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user