1
0
Fork 0
forked from alemi/upub

feat(web): clear pwd on login fail

not the best way to show failure but at least it does
This commit is contained in:
əlemi 2024-04-22 03:15:41 +02:00
parent 9c94caf8b4
commit af8310bfc9
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -42,13 +42,16 @@ pub fn LoginBox(
let email = username_ref.get().map(|x| x.value()).unwrap_or("".into()); let email = username_ref.get().map(|x| x.value()).unwrap_or("".into());
let password = password_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 { spawn_local(async move {
let auth = reqwest::Client::new() let Ok(res) = reqwest::Client::new()
.post(format!("{URL_BASE}/auth")) .post(format!("{URL_BASE}/auth"))
.json(&LoginForm { email, password }) .json(&LoginForm { email, password })
.send() .send()
.await.unwrap() .await
else { if let Some(rf) = password_ref.get() { rf.set_value("") }; return };
let Ok(auth) = res
.json::<AuthResponse>() .json::<AuthResponse>()
.await.unwrap(); .await
else { if let Some(rf) = password_ref.get() { rf.set_value("") }; return };
logging::log!("logged in until {}", auth.expires); logging::log!("logged in until {}", auth.expires);
// update our username and token cookies // update our username and token cookies
let username = auth.user.split('/').last().unwrap_or_default().to_string(); let username = auth.user.split('/').last().unwrap_or_default().to_string();