Skip to content

Commit

Permalink
fix: [security] password input renders password on success (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
roele authored Jun 2, 2024
1 parent c9fad0b commit e489a57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Binary file modified assets/input-password.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,14 @@ impl<'a> Input<'a> {
out.set_color(&self.theme.title)?;
write!(out, "{}", self.title)?;
out.set_color(&self.theme.selected_option)?;
writeln!(out, " {}", self.input)?;
writeln!(
out,
" {}",
match self.password {
true => (1..13).map(|_| '*').collect::<String>(),
false => self.input.to_string(),
}
)?;
out.reset()?;
Ok(std::str::from_utf8(out.as_slice()).unwrap().to_string())
}
Expand Down

0 comments on commit e489a57

Please sign in to comment.