From 29832574c11e40b4af8332b7046881f91b720bdb Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Mon, 11 Oct 2021 20:16:41 +0200 Subject: [PATCH] app: disable the login button while logging in --- app/src/components/login.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/components/login.rs b/app/src/components/login.rs index 529fd6a..eb65d71 100644 --- a/app/src/components/login.rs +++ b/app/src/components/login.rs @@ -13,7 +13,7 @@ pub struct LoginForm { error: Option, form: Form, // Used to keep the request alive long enough. - _task: Option, + task: Option, } /// The fields of the form, with the constraints. @@ -59,12 +59,12 @@ impl LoginForm { username, login_start_request: message, }; - self._task = Some(HostService::login_start( + self.task = Some(HostService::login_start( req, self.link .callback_once(move |r| Msg::AuthenticationStartResponse((state, r))), )?); - Ok(false) + Ok(true) } Msg::AuthenticationStartResponse((login_start, res)) => { let res = res.context("Could not log in (invalid response to login start)")?; @@ -84,13 +84,14 @@ impl LoginForm { server_data: res.server_data, credential_finalization: login_finish.message, }; - self._task = Some(HostService::login_finish( + self.task = Some(HostService::login_finish( req, self.link.callback_once(Msg::AuthenticationFinishResponse), )?); Ok(false) } Msg::AuthenticationFinishResponse(user_info) => { + self.task = None; self.on_logged_in .emit(user_info.context("Could not log in")?); Ok(true) @@ -109,7 +110,7 @@ impl Component for LoginForm { on_logged_in: props.on_logged_in, error: None, form: Form::::new(FormModel::default()), - _task: None, + task: None, } } @@ -119,6 +120,7 @@ impl Component for LoginForm { Err(e) => { ConsoleService::error(&e.to_string()); self.error = Some(e); + self.task = None; true } Ok(b) => b, @@ -170,6 +172,7 @@ impl Component for LoginForm {