fix: Use wp_authenticate + wp_set_auth_cookie + wp_set_current_user for proper session

This commit is contained in:
dwindown
2025-11-05 00:42:11 +07:00
parent 0f6696b361
commit ff29f95264
3 changed files with 20 additions and 105 deletions

View File

@@ -461,11 +461,12 @@ function AuthWrapper() {
);
}
if (window.WNW_CONFIG?.standaloneMode && !isAuthenticated) {
// Redirect to WordPress login with return URL
const returnUrl = encodeURIComponent(window.location.href);
window.location.href = `/wp-login.php?redirect_to=${returnUrl}`;
return null;
if (window.WNW_CONFIG?.standaloneMode && !isAuthenticated && location.pathname !== '/login') {
return <Navigate to="/login" replace />;
}
if (location.pathname === '/login' && isAuthenticated) {
return <Navigate to="/" replace />;
}
return (