summaryrefslogtreecommitdiff
path: root/views/mods/mod_revocation/page_form.phtml
diff options
context:
space:
mode:
authorRoger Rehnelt <noreply@maennchen1.de>2026-10-01 20:49:47 +0200
committerRoger Rehnelt <noreply@maennchen1.de>2026-10-01 20:49:47 +0200
commit520d8ea12b8f97bc847131e0abd752e4bf94891a (patch)
tree9c9fa667452bd4497c557f8967d7a3d149a30084 /views/mods/mod_revocation/page_form.phtml
parent8ee9bbe86a9dd6a4ea9bdb6e6d8ee983196460d7 (diff)
Widerruf: Nonce nicht mehr im gecachten HTML
Der Dialog holt die Nonce beim Öffnen; eine abgelaufene ersetzt der Server, Dialog und Formularseite senden einmal neu (K48). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'views/mods/mod_revocation/page_form.phtml')
-rw-r--r--views/mods/mod_revocation/page_form.phtml23
1 files changed, 20 insertions, 3 deletions
diff --git a/views/mods/mod_revocation/page_form.phtml b/views/mods/mod_revocation/page_form.phtml
index 6dda801..f7849ff 100644
--- a/views/mods/mod_revocation/page_form.phtml
+++ b/views/mods/mod_revocation/page_form.phtml
@@ -112,7 +112,8 @@
const form = document.getElementById('wpsg_revocation_page_form');
if (form === null) return;
- const nonce = '<?php echo \wp_create_nonce('wpsg_mod_revocation_nonce'); ?>';
+ // Kann aus dem Seiten-Cache kommen; ist sie abgelaufen, schickt der Server eine frische mit (K48)
+ let nonce = <?php echo \wp_json_encode(\wp_create_nonce('wpsg_mod_revocation_nonce')); ?>;
const endpoint = '<?php echo \admin_url('admin-ajax.php'); ?>?action=wpsg_mod_revocation&do=ajaxDialogSubmit';
const msg = document.getElementById('wpsg_revocation_page_msg');
const button = form.querySelector('.wpsg_revocation_page_submit');
@@ -155,11 +156,27 @@
const form_data = formDataToObject(new FormData(form));
- fetch(endpoint, {
+ const post = retry => fetch(endpoint, {
method: 'POST',
+ credentials: 'same-origin',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ nonce: nonce, form_data: form_data })
- }).then(res => res.json()).then(res => {
+ }).then(res => res.json().then(json => {
+
+ if (res.status === 403 && retry && (json?.data?.code ?? '') === 'wpsg_nonce') {
+
+ nonce = json.data.nonce;
+ return post(false);
+
+ }
+
+ if (!res.ok) throw new Error(res.status);
+
+ return json;
+
+ }));
+
+ post(true).then(res => {
button.disabled = false;