From 4145887a9b083e910027ae57d604f315a884f7ed Mon Sep 17 00:00:00 2001 From: Martin Gross Date: Thu, 16 Dec 2021 18:35:09 +0100 Subject: [PATCH] Web checkin: Redirect user to login if session expired (#2383) Co-authored-by: Raphael Michel --- .../static/pretixplugins/webcheckin/components/app.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pretix/plugins/webcheckin/static/pretixplugins/webcheckin/components/app.vue b/src/pretix/plugins/webcheckin/static/pretixplugins/webcheckin/components/app.vue index 587f491bc..c9d21c17e 100644 --- a/src/pretix/plugins/webcheckin/static/pretixplugins/webcheckin/components/app.vue +++ b/src/pretix/plugins/webcheckin/static/pretixplugins/webcheckin/components/app.vue @@ -360,6 +360,9 @@ export default { reason: 'invalid', } } + if (!response.ok && [401, 403].includes(response.status)) { + window.location.href = '/control/login?next=' + encodeURIComponent(window.location.pathname + window.location.search + window.location.hash); + } if (!response.ok && response.status != 400) { throw new Error("HTTP status " + response.status); } @@ -448,7 +451,12 @@ export default { window.clearInterval(this.clearTimeout) fetch(this.$root.api.lists + this.checkinlist.id + '/positions/?ignore_status=true&expand=subevent&expand=item&expand=variation&check_rules=true&search=' + encodeURIComponent(this.query)) - .then(response => response.json()) + .then(response => { + if (!response.ok && [401, 403].includes(response.status)) { + window.location.href = '/control/login?next=' + encodeURIComponent(window.location.pathname + window.location.search + window.location.hash); + } + response.json() + }) .then(data => { this.searchLoading = false if (data.results) {