fix: Reload page after login to get fresh cookies and nonce from PHP
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user