Add detailed logging to login handler and use full page reload for auth navigation
All checks were successful
Build MIPS Binary / build (push) Successful in 4m7s

This commit is contained in:
spinline
2026-02-07 15:28:44 +03:00
parent 08f2f540fe
commit e3eb5fbca9
3 changed files with 31 additions and 11 deletions

View File

@@ -20,6 +20,8 @@ pub fn Login() -> impl IntoView {
set_loading.set(true);
set_error.set(None);
logging::log!("Attempting login for user: {}", username.get());
spawn_local(async move {
let req = LoginRequest {
username: username.get(),
@@ -32,15 +34,19 @@ pub fn Login() -> impl IntoView {
match client.send().await {
Ok(resp) => {
logging::log!("Login response status: {}", resp.status());
if resp.ok() {
// Redirect to home on success
let navigate = use_navigate();
navigate("/", Default::default());
logging::log!("Login successful, redirecting...");
// Force a full reload to re-run auth checks in App.rs
let _ = window().location().set_href("/");
} else {
let text = resp.text().await.unwrap_or_default();
logging::error!("Login failed: {}", text);
set_error.set(Some("Kullanıcı adı veya şifre hatalı".to_string()));
}
}
Err(_) => {
Err(e) => {
logging::error!("Network error: {}", e);
set_error.set(Some("Bağlantı hatası".to_string()));
}
}

View File

@@ -49,9 +49,8 @@ pub fn Setup() -> impl IntoView {
match client.send().await {
Ok(resp) => {
if resp.ok() {
// Redirect to login after setup
let navigate = use_navigate();
navigate("/login", Default::default());
// Redirect to login after setup (full reload to be safe)
let _ = window().location().set_href("/login");
} else {
let text = resp.text().await.unwrap_or_default();
set_error.set(Some(format!("Hata: {}", text)));