From 47e77f9fac1155c536b2b87fec552c7fcce66fa6 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 01 Jun 2026 18:06:34 +0000
Subject: [PATCH] =Timeline block fixes. Next up: adding article schema classes

---
 assets/js/concise/AuthManager.js |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/assets/js/concise/AuthManager.js b/assets/js/concise/AuthManager.js
index 3d8c381..760934f 100644
--- a/assets/js/concise/AuthManager.js
+++ b/assets/js/concise/AuthManager.js
@@ -74,8 +74,10 @@
 	 */
 	async fetch(url, options = {}) {
 		const attempt = async (retryCount = 0) => {
+			const isFormData = options.body instanceof FormData;
+
 			const headers = {
-				'Content-Type': 'application/json',
+				...(!isFormData && { 'Content-Type': 'application/json' }),
 				...options.headers,
 				'X-WP-Nonce': this.getNonce()
 			};
@@ -91,7 +93,7 @@
 				if (result.code === 'rest_cookie_invalid_nonce' || result.message?.includes('Cookie check')) {
 					console.log('Nonce invalid, refreshing auth...');
 					await this.refresh();
-					return attempt(1);
+					return attempt(retryCount + 1);
 				}
 			}
 
@@ -140,9 +142,16 @@
 	 * Set authentication data
 	 */
 	setAuthData(authData) {
+		const wasAuthenticated = this.initialized && this.authenticated;
+
 		this.authenticated = authData.authenticated || false;
 		this.user = authData.user || false;
 		this.nonces = authData.nonces || {};
+
+		// Session expired — was logged in, now isn't
+		if (wasAuthenticated && !this.authenticated) {
+			window.location.href = `/login?redirect_to=${encodeURIComponent(window.location.href)}`;
+		}
 	}
 
 	/**

--
Gitblit v1.10.0