diff --git a/src/client.rs b/src/client.rs index 5f5f34cd0..e1e4c8034 100644 --- a/src/client.rs +++ b/src/client.rs @@ -3548,7 +3548,7 @@ pub async fn handle_hash( hash: Hash, interface: &impl Interface, peer: &mut Stream, -) { +) -> bool { lc.write().unwrap().hash = hash.clone(); // Take care of password application order @@ -3572,7 +3572,7 @@ pub async fn handle_hash( lc.write().unwrap().allow_switch_back_once(); send_switch_login_request(lc.clone(), peer, uuid).await; lc.write().unwrap().password_source = Default::default(); - return; + return true; } } } @@ -3587,7 +3587,7 @@ pub async fn handle_hash( let mut msg = Message::new(); msg.set_misc(misc); allow_err!(peer.send(&msg).await); - return; + return false; } } // last password @@ -3651,7 +3651,7 @@ pub async fn handle_hash( interface.msgbox("terminal-admin-login", "", "", ""); } lc.write().unwrap().hash = hash; - return; + return true; } let password = if password.is_empty() { @@ -3677,6 +3677,7 @@ pub async fn handle_hash( send_login(lc.clone(), os_username, os_password, password, peer).await; lc.write().unwrap().hash = hash; + true } #[inline] @@ -3804,7 +3805,7 @@ pub trait Interface: Send + Clone + 'static + Sized { fn on_error(&self, err: &str) { self.msgbox("error", "Error", err, ""); } - async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream); + async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream) -> bool; async fn handle_login_from_ui( &self, os_username: String, diff --git a/src/client/io_loop.rs b/src/client/io_loop.rs index 4636c54f8..1af691429 100644 --- a/src/client/io_loop.rs +++ b/src/client/io_loop.rs @@ -1353,9 +1353,13 @@ impl Remote { } } Some(message::Union::Hash(hash)) => { - self.handler + if !self + .handler .handle_hash(&self.handler.password.clone(), hash, peer) - .await; + .await + { + return false; + } } Some(message::Union::LoginResponse(lr)) => match lr.union { Some(login_response::Union::Error(err)) => { diff --git a/src/port_forward.rs b/src/port_forward.rs index 8b190fb1e..7a3f8715c 100644 --- a/src/port_forward.rs +++ b/src/port_forward.rs @@ -150,7 +150,9 @@ async fn connect_and_login( let msg_in = Message::parse_from_bytes(&bytes)?; match msg_in.union { Some(message::Union::Hash(hash)) => { - interface.handle_hash(password, hash, &mut stream).await; + if !interface.handle_hash(password, hash, &mut stream).await { + return Ok(None); + } } Some(message::Union::LoginResponse(lr)) => match lr.union { Some(login_response::Union::Error(err)) => { diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index bf2e04c6b..9e4128dca 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -1878,8 +1878,8 @@ impl Interface for Session { } } - async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream) { - handle_hash(self.lc.clone(), pass, hash, self, peer).await; + async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream) -> bool { + handle_hash(self.lc.clone(), pass, hash, self, peer).await } async fn handle_login_from_ui(