fix: Reload page after login to get fresh cookies and nonce from PHP

This commit is contained in:
dwindown
2025-11-05 00:14:19 +07:00
parent 15f0bcb4e4
commit eecb34e968

View File

@@ -32,18 +32,9 @@ export function Login() {
const data = await response.json(); const data = await response.json();
if (response.ok && data.success) { if (response.ok && data.success) {
// Update global config // CRITICAL: Reload page to get fresh cookies and nonce from PHP
window.WNW_CONFIG.isAuthenticated = true; // wp_signon sets cookies but we need PHP to render with proper auth state
window.WNW_CONFIG.currentUser = data.user; window.location.href = window.location.origin + window.location.pathname;
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');
} else { } else {
setError(data.message || __('Invalid username or password')); setError(data.message || __('Invalid username or password'));
} }