Skip to content

Commit

Permalink
update rpassword to 7.2.0 and add some debug logs (#325)
Browse files Browse the repository at this point in the history
related: #324
  • Loading branch information
dyc3 committed Sep 28, 2023
1 parent 4fb0e4c commit 04295dc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
15 changes: 13 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ path = "src/main.rs"
anyhow = "^1.0"
base64 = "0.21.2"
text_io = "0.1.8"
rpassword = "5.0"
rpassword = "7.2.0"
reqwest = { version = "0.11", default-features = false, features = ["blocking", "json", "cookies", "gzip", "rustls-tls"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
5 changes: 2 additions & 3 deletions src/commands/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ where
error!("Passkey cannot be empty, try again.");
continue;
}
let passkey_confirm =
rpassword::prompt_password_stdout("Confirm encryption passkey: ")
.map(SecretString::new)?;
let passkey_confirm = rpassword::prompt_password("Confirm encryption passkey: ")
.map(SecretString::new)?;
if passkey1.expose_secret() == passkey_confirm.expose_secret() {
passkey = Some(passkey1);
break;
Expand Down
1 change: 1 addition & 0 deletions src/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ fn do_login_impl<T: Transport + Clone>(
password: SecretString,
account: Option<&SteamGuardAccount>,
) -> anyhow::Result<Tokens> {
debug!("starting login");
let mut login = UserLogin::new(transport.clone(), build_device_details());

let mut password = password;
Expand Down
13 changes: 9 additions & 4 deletions src/tui.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::Context;
use crossterm::{
cursor,
event::{Event, KeyCode, KeyEvent, KeyModifiers},
Expand All @@ -6,6 +7,7 @@ use crossterm::{
terminal::{Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen},
QueueableCommand,
};
use log::debug;
use secrecy::SecretString;
use std::collections::HashSet;
use std::io::{stderr, stdout, Write};
Expand Down Expand Up @@ -245,18 +247,21 @@ pub(crate) fn pause() {
}
}

pub(crate) fn prompt_passkey() -> std::io::Result<SecretString> {
pub(crate) fn prompt_passkey() -> anyhow::Result<SecretString> {
debug!("prompting for passkey");
loop {
let raw = rpassword::prompt_password_stdout("Enter encryption passkey: ")?;
let raw = rpassword::prompt_password("Enter encryption passkey: ")
.context("prompting for passkey")?;
if !raw.is_empty() {
return Ok(SecretString::new(raw));
}
}
}

pub(crate) fn prompt_password() -> std::io::Result<SecretString> {
pub(crate) fn prompt_password() -> anyhow::Result<SecretString> {
debug!("prompting for password");
loop {
let raw = rpassword::prompt_password_stdout("Password: ")?;
let raw = rpassword::prompt_password("Password: ").context("prompting for password")?;
if !raw.is_empty() {
return Ok(SecretString::new(raw));
}
Expand Down

0 comments on commit 04295dc

Please sign in to comment.