From 487208278040096213b0929a0682db30ebe70fff Mon Sep 17 00:00:00 2001 From: Mira Date: Mon, 24 Feb 2025 17:15:03 +0100 Subject: [PATCH] Prioritize widget-provided cookie consent information over localStorage (Z#23181715) (#4862) * Prioritize widget-provided cookie consent information over localStorage * Hide cookie-consent-reopen link if external consent info from widget present --- .../pretixpresale/js/ui/cookieconsent.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/pretix/static/pretixpresale/js/ui/cookieconsent.js b/src/pretix/static/pretixpresale/js/ui/cookieconsent.js index 873d4b8bc..bc109db38 100644 --- a/src/pretix/static/pretixpresale/js/ui/cookieconsent.js +++ b/src/pretix/static/pretixpresale/js/ui/cookieconsent.js @@ -31,7 +31,16 @@ $(function () { var show_dialog = !storage_val; var consent_checkboxes = $("#cookie-consent-details input[type=checkbox][name]"); var consent_modal = $("#cookie-consent-modal"); - if (storage_val) { + var widget_consent = $("#cookie-consent-from-widget").text(); + if (widget_consent) { + widget_consent = JSON.parse(widget_consent); + storage_val = {} + consent_checkboxes.each(function () { + this.checked = storage_val[this.name] = widget_consent.indexOf(this.name) > -1; + }) + show_dialog = false; + $("#cookie-consent-reopen").hide(); + } else if (storage_val) { storage_val = JSON.parse(storage_val); consent_checkboxes.each(function () { if (typeof storage_val[this.name] === "undefined") { @@ -43,14 +52,6 @@ $(function () { }) } else { storage_val = {} - var consented = $("#cookie-consent-from-widget").text(); - if (consented) { - consented = JSON.parse(consented); - consent_checkboxes.each(function () { - this.checked = storage_val[this.name] = consented.indexOf(this.name) > -1; - }) - show_dialog = false - } } update_consent(storage_val);