From eecb34e9689831d16e329277b741b48042d653fe Mon Sep 17 00:00:00 2001 From: dwindown Date: Wed, 5 Nov 2025 00:14:19 +0700 Subject: [PATCH] fix: Reload page after login to get fresh cookies and nonce from PHP --- admin-spa/src/routes/Login.tsx | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/admin-spa/src/routes/Login.tsx b/admin-spa/src/routes/Login.tsx index e44e166..6810a9b 100644 --- a/admin-spa/src/routes/Login.tsx +++ b/admin-spa/src/routes/Login.tsx @@ -32,18 +32,9 @@ export function Login() { const data = await response.json(); if (response.ok && data.success) { - // Update global config - window.WNW_CONFIG.isAuthenticated = true; - window.WNW_CONFIG.currentUser = data.user; - window.WNW_CONFIG.nonce = data.nonce; - - // CRITICAL: Also update WNW_API.nonce for API requests - if (window.WNW_API) { - window.WNW_API.nonce = data.nonce; - } - - // Redirect to dashboard (no reload needed, auth state is updated) - navigate('/dashboard'); + // CRITICAL: Reload page to get fresh cookies and nonce from PHP + // wp_signon sets cookies but we need PHP to render with proper auth state + window.location.href = window.location.origin + window.location.pathname; } else { setError(data.message || __('Invalid username or password')); }