mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
add option to type usernames as well as passwords
passwords is the "quick default", you have to pop down by one on the menu to type a username. This should address #401.
This commit is contained in:
parent
df663c32d2
commit
93a2dc0515
3 changed files with 35 additions and 12 deletions
|
|
@ -252,11 +252,18 @@
|
||||||
"zh": "添加新项目"
|
"zh": "添加新项目"
|
||||||
},
|
},
|
||||||
"vault.menu_autotype": {
|
"vault.menu_autotype": {
|
||||||
"en": "Autotype",
|
"en": "Autotype password",
|
||||||
"en-tts": "Autotype",
|
"en-tts": "Autotype password",
|
||||||
"fr": "Autotype",
|
"fr": "Autotype mot de passe",
|
||||||
"ja": "自動的に入力",
|
"ja": "パスワードの自動入力",
|
||||||
"zh": "自动输入"
|
"zh": "自动输入密码"
|
||||||
|
},
|
||||||
|
"vault.menu_autotype_username": {
|
||||||
|
"en": "Autotype username",
|
||||||
|
"en-tts": "Autotype username",
|
||||||
|
"fr": "Autotype nom d'utilisateur",
|
||||||
|
"ja": "ユーザー名を自動的に入力",
|
||||||
|
"zh": "自动输入用户名"
|
||||||
},
|
},
|
||||||
"vault.menu_change_font": {
|
"vault.menu_change_font": {
|
||||||
"en": "Change list font",
|
"en": "Change list font",
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ use crate::vendor_commands::VendorSession;
|
||||||
|
|
||||||
use ux::framework::{VaultUx, DEFAULT_FONT, FONT_LIST, name_to_style};
|
use ux::framework::{VaultUx, DEFAULT_FONT, FONT_LIST, name_to_style};
|
||||||
use xous_ipc::Buffer;
|
use xous_ipc::Buffer;
|
||||||
use xous::{send_message, Message, msg_blocking_scalar_unpack};
|
use xous::{send_message, Message, msg_blocking_scalar_unpack, msg_scalar_unpack};
|
||||||
use usbd_human_interface_device::device::fido::*;
|
use usbd_human_interface_device::device::fido::*;
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
|
|
||||||
|
|
@ -612,10 +612,10 @@ fn main() -> ! {
|
||||||
allow_totp_rendering.store(true, Ordering::SeqCst);
|
allow_totp_rendering.store(true, Ordering::SeqCst);
|
||||||
vaultux.update_mode();
|
vaultux.update_mode();
|
||||||
}
|
}
|
||||||
Some(VaultOp::MenuAutotype) => {
|
Some(VaultOp::MenuAutotype) => msg_scalar_unpack!(msg, select_username, _, _, _, {
|
||||||
allow_totp_rendering.store(false, Ordering::SeqCst);
|
allow_totp_rendering.store(false, Ordering::SeqCst);
|
||||||
modals.dynamic_notification(Some(t!("vault.autotyping", locales::LANG)), None).ok();
|
modals.dynamic_notification(Some(t!("vault.autotyping", locales::LANG)), None).ok();
|
||||||
match vaultux.autotype() {
|
match vaultux.autotype(select_username == 1) {
|
||||||
Err(xous::Error::UseBeforeInit) => { // USB not plugged in
|
Err(xous::Error::UseBeforeInit) => { // USB not plugged in
|
||||||
modals.dynamic_notification_update(Some(t!("vault.error.usb_error", locales::LANG)), None).ok();
|
modals.dynamic_notification_update(Some(t!("vault.error.usb_error", locales::LANG)), None).ok();
|
||||||
tt.sleep_ms(ERR_TIMEOUT_MS).unwrap();
|
tt.sleep_ms(ERR_TIMEOUT_MS).unwrap();
|
||||||
|
|
@ -651,7 +651,7 @@ fn main() -> ! {
|
||||||
let buf = Buffer::into_buf(entry).expect("IPC error");
|
let buf = Buffer::into_buf(entry).expect("IPC error");
|
||||||
buf.send(actions_conn, ActionOp::UpdateOneItem.to_u32().unwrap()).expect("messaging error");
|
buf.send(actions_conn, ActionOp::UpdateOneItem.to_u32().unwrap()).expect("messaging error");
|
||||||
}
|
}
|
||||||
}
|
}),
|
||||||
Some(VaultOp::MenuDeleteStage1) => {
|
Some(VaultOp::MenuDeleteStage1) => {
|
||||||
// stage 1 happens here because the filtered list and selection entry are in the responsive UX section.
|
// stage 1 happens here because the filtered list and selection entry are in the responsive UX section.
|
||||||
if let Some(entry) = vaultux.selected_entry() {
|
if let Some(entry) = vaultux.selected_entry() {
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,7 @@ impl VaultUx {
|
||||||
pub fn swap_submenu(&mut self) {
|
pub fn swap_submenu(&mut self) {
|
||||||
// always call delete on the potential optional items, to return us to a known state
|
// always call delete on the potential optional items, to return us to a known state
|
||||||
self.menu_mgr.delete_item(t!("vault.menu_autotype", locales::LANG));
|
self.menu_mgr.delete_item(t!("vault.menu_autotype", locales::LANG));
|
||||||
|
self.menu_mgr.delete_item(t!("vault.menu_autotype_username", locales::LANG));
|
||||||
self.menu_mgr.delete_item(t!("vault.menu_addnew", locales::LANG));
|
self.menu_mgr.delete_item(t!("vault.menu_addnew", locales::LANG));
|
||||||
match *self.mode.lock().unwrap() {
|
match *self.mode.lock().unwrap() {
|
||||||
VaultMode::Fido => (),
|
VaultMode::Fido => (),
|
||||||
|
|
@ -201,6 +202,16 @@ impl VaultUx {
|
||||||
},
|
},
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
self.menu_mgr.insert_item(
|
||||||
|
MenuItem {
|
||||||
|
name: xous_ipc::String::from_str(t!("vault.menu_autotype_username", locales::LANG)),
|
||||||
|
action_conn: Some(self.main_conn),
|
||||||
|
action_opcode: VaultOp::MenuAutotype.to_u32().unwrap(),
|
||||||
|
action_payload: MenuPayload::Scalar([1, 0, 0, 0]),
|
||||||
|
close_on_select: true,
|
||||||
|
},
|
||||||
|
0
|
||||||
|
);
|
||||||
self.menu_mgr.insert_item(
|
self.menu_mgr.insert_item(
|
||||||
MenuItem {
|
MenuItem {
|
||||||
name: xous_ipc::String::from_str(t!("vault.menu_autotype", locales::LANG)),
|
name: xous_ipc::String::from_str(t!("vault.menu_autotype", locales::LANG)),
|
||||||
|
|
@ -555,7 +566,7 @@ impl VaultUx {
|
||||||
pub(crate) fn set_autotype_delay_ms(&self, rate: usize) {
|
pub(crate) fn set_autotype_delay_ms(&self, rate: usize) {
|
||||||
self.usb_dev.set_autotype_delay_ms(rate);
|
self.usb_dev.set_autotype_delay_ms(rate);
|
||||||
}
|
}
|
||||||
pub(crate) fn autotype(&mut self) -> Result<(), xous::Error> {
|
pub(crate) fn autotype(&mut self, type_username: bool) -> Result<(), xous::Error> {
|
||||||
let mode_cache = (*self.mode.lock().unwrap()).clone();
|
let mode_cache = (*self.mode.lock().unwrap()).clone();
|
||||||
match mode_cache {
|
match mode_cache {
|
||||||
VaultMode::Password => {
|
VaultMode::Password => {
|
||||||
|
|
@ -574,14 +585,19 @@ impl VaultUx {
|
||||||
match record.read_to_end(&mut data) {
|
match record.read_to_end(&mut data) {
|
||||||
Ok(_len) => {
|
Ok(_len) => {
|
||||||
if let Some(mut pw) = crate::storage::PasswordRecord::try_from(data).ok() {
|
if let Some(mut pw) = crate::storage::PasswordRecord::try_from(data).ok() {
|
||||||
match self.usb_dev.send_str(&pw.password) {
|
let to_type = if type_username {
|
||||||
|
&pw.username
|
||||||
|
} else {
|
||||||
|
&pw.password
|
||||||
|
};
|
||||||
|
match self.usb_dev.send_str(to_type) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
pw.count += 1;
|
pw.count += 1;
|
||||||
pw.atime = atime;
|
pw.atime = atime;
|
||||||
pw
|
pw
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("couldn't autotype password: {:?}", e);
|
log::error!("couldn't autotype: {:?}", e);
|
||||||
return Err(xous::Error::UseBeforeInit);
|
return Err(xous::Error::UseBeforeInit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue