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();
|
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'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user