From 94472338b2c17d2d992a4f0cd167adc4b505aa80 Mon Sep 17 00:00:00 2001 From: Jovi Hsu Date: Wed, 26 Oct 2022 04:57:55 +0000 Subject: [PATCH] Add API to read credentials --- webrdp/src/lib.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/webrdp/src/lib.rs b/webrdp/src/lib.rs index 08221be..fef100c 100644 --- a/webrdp/src/lib.rs +++ b/webrdp/src/lib.rs @@ -14,10 +14,13 @@ extern "C" { fn alert(s: &str); pub fn setClipBoard(s: String); pub fn getClipBoard() -> String; + fn prompt(msg: &str) -> String; } -fn read_credentials() { - unimplemented!(); +fn read_credentials(user: &mut String, password: &mut String, domain: &mut String) { + *user = prompt("User:"); + *password = prompt("Password:"); + *domain = prompt("Domain:"); } fn start_websocket() -> Result<(), JsValue> { @@ -38,9 +41,15 @@ fn start_websocket() -> Result<(), JsValue> { ); spawn_local(async move { - let mut rdp = Rdp::new(&url, "", "", ""); + let mut username = String::new(); + let mut password = String::new(); + let mut domain = String::new(); + read_credentials(&mut username, &mut password, &mut domain); + let mut rdp = Rdp::new(&url, &username, &password, &domain); while !rdp.start().await { warn!("Wrong credientials"); + read_credentials(&mut username, &mut password, &mut domain); + rdp = Rdp::new(&url, &username, &password, &domain); } rdp.main_loop().await });