mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
implement totp auto-typing
also extend totp updater to return the string so we can use that result to type a code
This commit is contained in:
parent
8a980c1c81
commit
7e5aaa805d
1 changed files with 22 additions and 4 deletions
|
|
@ -85,6 +85,8 @@ pub struct VaultUi {
|
|||
item_height: isize,
|
||||
style: GlyphStyle,
|
||||
storage_manager: Manager,
|
||||
|
||||
usb_dev: usb_bao1x::UsbHid,
|
||||
}
|
||||
|
||||
impl VaultUi {
|
||||
|
|
@ -118,6 +120,7 @@ impl VaultUi {
|
|||
item_height: height / glyph_height,
|
||||
style,
|
||||
storage_manager: Manager::new(xns),
|
||||
usb_dev: usb_bao1x::UsbHid::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -130,17 +133,27 @@ impl VaultUi {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn update_selected_totp_code(&mut self) {
|
||||
pub(crate) fn update_selected_totp_code(&mut self) -> Option<String> {
|
||||
if self.totp_list.len() > 0 {
|
||||
let selected = self.totp_list.get_selected();
|
||||
let mut locked_lists = self.item_lists.lock().unwrap();
|
||||
let full_list = locked_lists.full_list(VaultMode::Totp);
|
||||
if let Some(selected_item) = full_list.iter().find(|item| item.name() == selected) {
|
||||
match crate::totp::db_str_to_code(&selected_item.extra) {
|
||||
Ok(s) => self.totp_code = Some(s),
|
||||
_ => self.totp_code = None,
|
||||
Ok(s) => {
|
||||
self.totp_code = Some(s.clone());
|
||||
Some(s)
|
||||
}
|
||||
_ => {
|
||||
self.totp_code = None;
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -473,7 +486,12 @@ impl VaultUi {
|
|||
NavDir::Down => {
|
||||
self.totp_list.key_action('↓');
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
_ => {
|
||||
if let Some(code) = self.update_selected_totp_code() {
|
||||
// ignore USB errors while sending code
|
||||
self.usb_dev.send_str(&code).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
self.totp_code = None;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue