diff --git a/README.md b/README.md index 5106f14..6deda10 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ two other TUI clients and Element Web: | Message editing | ✔️ | ✔️ | ❌ | ✔️ | | Room upgrades | ❌ ([#41]) | ✔️ | ❌ | ✔️ | | Localisations | ❌ | 1 | ❌ | 44 | -| SSO Support | ✔️ | ✔️ | ✔️ | ✔️ | +| SSO Support | ✔️ | ✔️ | ✔️ | ✔️ | ## License diff --git a/src/main.rs b/src/main.rs index 7d5e185..7c5c148 100644 --- a/src/main.rs +++ b/src/main.rs @@ -642,13 +642,12 @@ async fn login(worker: Requester, settings: &ApplicationSettings) -> IambResult< } loop { - println!("Please select login type"); - println!("[P]assword / [s]ingle sign on"); + println!("Please select login type: [p]assword / [s]ingle sign on"); let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); - let login_style = match input.chars().nth(0).map(|x| char::to_ascii_lowercase(&x)) { + let login_style = match input.chars().next().map(|c| c.to_ascii_lowercase()) { None | Some('p') => { let password = rpassword::prompt_password("Password: ")?; LoginStyle::Password(password) @@ -656,7 +655,7 @@ async fn login(worker: Requester, settings: &ApplicationSettings) -> IambResult< Some('s') => LoginStyle::SingleSignOn, Some(_) => { println!("Failed to login. Please enter 'p' or 's'"); - break; + continue; }, }; diff --git a/src/worker.rs b/src/worker.rs index a2996f1..8fc7ef3 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -1021,8 +1021,13 @@ impl ClientWorker { LoginStyle::SingleSignOn => { let resp = client .login_sso(|url| { + let opened = format!( + "The following URL should have been opened in your browser:\n {url}" + ); + async move { - println!("Open {} in a browser", url); + tokio::task::spawn_blocking(move || open::that(url)); + println!("\n{opened}\n"); Ok(()) } })