From 69ad2c7e71e32e5753587911036e56b68baf7a45 Mon Sep 17 00:00:00 2001 From: th Date: Tue, 14 Apr 2026 21:23:48 +0200 Subject: [PATCH] fixes: password form wrap, collab-buckets csrf race Co-Authored-By: Claude Opus 4.6 (1M context) --- public/index.php | 4 +++- public/plugins/collab-buckets/collab-buckets.js | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/public/index.php b/public/index.php index 3c9c66d..ad135ad 100644 --- a/public/index.php +++ b/public/index.php @@ -1925,6 +1925,7 @@ if (str_starts_with($route, '/api/')) {
change password
+
@@ -1938,9 +1939,10 @@ if (str_starts_with($route, '/api/')) {
- +
+
diff --git a/public/plugins/collab-buckets/collab-buckets.js b/public/plugins/collab-buckets/collab-buckets.js index 8713873..283533a 100644 --- a/public/plugins/collab-buckets/collab-buckets.js +++ b/public/plugins/collab-buckets/collab-buckets.js @@ -908,10 +908,18 @@ async function init() { startPolling(); } +// Defer init until the CSRF token is live — `checkAuth()` sets it async on +// boot, and firing POST /api/collab-buckets/poll before that racing lookup +// resolves returns 403. If the token is already in the util state when we +// load (e.g. fast reload, cached session), kick off init straight away. +function bootWhenCsrfReady() { + if (hyprcrd?.util?.csrf?.()) { init(); return; } + hyprcrd?.hooks?.on?.('csrf.ready', () => init()); +} if (document.readyState === 'loading') { - document.addEventListener('DOMContentLoaded', init, { once: true }); + document.addEventListener('DOMContentLoaded', bootWhenCsrfReady, { once: true }); } else { - init(); + bootWhenCsrfReady(); } hyprcrd.registerPlugin?.({