From af8310bfc96acebfac729461fcba6613f5ea7fe8 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 22 Apr 2024 03:15:41 +0200 Subject: [PATCH] feat(web): clear pwd on login fail not the best way to show failure but at least it does --- web/src/auth.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/src/auth.rs b/web/src/auth.rs index 13da1d0f..46c03a64 100644 --- a/web/src/auth.rs +++ b/web/src/auth.rs @@ -42,13 +42,16 @@ pub fn LoginBox( let email = username_ref.get().map(|x| x.value()).unwrap_or("".into()); let password = password_ref.get().map(|x| x.value()).unwrap_or("".into()); spawn_local(async move { - let auth = reqwest::Client::new() + let Ok(res) = reqwest::Client::new() .post(format!("{URL_BASE}/auth")) .json(&LoginForm { email, password }) .send() - .await.unwrap() + .await + else { if let Some(rf) = password_ref.get() { rf.set_value("") }; return }; + let Ok(auth) = res .json::() - .await.unwrap(); + .await + else { if let Some(rf) = password_ref.get() { rf.set_value("") }; return }; logging::log!("logged in until {}", auth.expires); // update our username and token cookies let username = auth.user.split('/').last().unwrap_or_default().to_string();