Skip to content

Commit 008b36f

Browse files
feat: censor password with toggle keybind (#30)
1 parent 35ba908 commit 008b36f

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/app.rs

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub struct App {
5656
pub passkey_sender: Sender<String>,
5757
pub cancel_signal_sender: Sender<()>,
5858
pub passkey_input: Input,
59+
pub show_password: bool,
5960
pub mode: Mode,
6061
pub selected_mode: Mode,
6162
pub current_mode: Mode,
@@ -113,6 +114,7 @@ impl App {
113114
let current_mode = adapter.device.mode.clone();
114115

115116
let (passkey_sender, passkey_receiver) = async_channel::unbounded();
117+
let show_password = false;
116118
let (cancel_signal_sender, cancel_signal_receiver) = async_channel::unbounded();
117119

118120
let authentication_required = Arc::new(AtomicBool::new(false));
@@ -153,6 +155,7 @@ impl App {
153155
passkey_sender,
154156
cancel_signal_sender,
155157
passkey_input: Input::default(),
158+
show_password,
156159
mode,
157160
selected_mode: Mode::Station,
158161
current_mode,

src/handler.rs

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ pub async fn handle_key_events(
6060
app.cancel_auth().await?;
6161
app.focused_block = FocusedBlock::Device;
6262
}
63+
64+
KeyCode::Tab => {
65+
app.show_password = !app.show_password;
66+
}
67+
6368
_ => {
6469
app.passkey_input
6570
.handle_event(&crossterm::event::Event::Key(key_event));

src/ui.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ pub fn render(app: &mut App, frame: &mut Frame) {
2121
// Auth Popup
2222
if app.authentication_required.load(Ordering::Relaxed) {
2323
app.focused_block = FocusedBlock::AuthKey;
24-
Auth.render(frame, app.passkey_input.value());
24+
let censored_password = "*".repeat(app.passkey_input.value().len());
25+
if !app.show_password {
26+
Auth.render(frame, &censored_password);
27+
} else {
28+
Auth.render(frame, app.passkey_input.value());
29+
}
2530
}
2631

2732
// Access Point Popup

0 commit comments

Comments
 (0)