feat(web): clear pwd on login fail
not the best way to show failure but at least it does
This commit is contained in:
parent
9c94caf8b4
commit
af8310bfc9
1 changed files with 6 additions and 3 deletions
|
@ -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();
|
||||||
|
|
Loading…
Reference in a new issue