fix not prompting for password for decrypt
This commit is contained in:
parent
1ee063f58e
commit
2678961a4c
1 changed files with 23 additions and 1 deletions
24
src/main.rs
24
src/main.rs
|
@ -306,6 +306,28 @@ fn get_mafiles_dir() -> String {
|
||||||
return paths[0].to_str().unwrap().into();
|
return paths[0].to_str().unwrap().into();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_accounts_with_prompts(manifest: &mut accountmanager::Manifest) -> anyhow::Result<()> {
|
||||||
|
loop {
|
||||||
|
match manifest.load_accounts() {
|
||||||
|
Ok(_) => return Ok(()),
|
||||||
|
Err(
|
||||||
|
accountmanager::ManifestAccountLoadError::MissingPasskey
|
||||||
|
| accountmanager::ManifestAccountLoadError::IncorrectPasskey,
|
||||||
|
) => {
|
||||||
|
if manifest.has_passkey() {
|
||||||
|
error!("Incorrect passkey");
|
||||||
|
}
|
||||||
|
let passkey = rpassword::prompt_password_stdout("Enter encryption passkey: ").ok();
|
||||||
|
manifest.submit_passkey(passkey);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("Could not load accounts: {}", e);
|
||||||
|
return Err(e.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn do_subcmd_debug(args: cli::ArgsDebug) -> anyhow::Result<()> {
|
fn do_subcmd_debug(args: cli::ArgsDebug) -> anyhow::Result<()> {
|
||||||
if args.demo_conf_menu {
|
if args.demo_conf_menu {
|
||||||
demos::demo_confirmation_menu();
|
demos::demo_confirmation_menu();
|
||||||
|
@ -631,7 +653,7 @@ fn do_subcmd_decrypt(
|
||||||
_args: cli::ArgsDecrypt,
|
_args: cli::ArgsDecrypt,
|
||||||
manifest: &mut accountmanager::Manifest,
|
manifest: &mut accountmanager::Manifest,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
manifest.load_accounts()?;
|
load_accounts_with_prompts(manifest)?;
|
||||||
for entry in &mut manifest.entries {
|
for entry in &mut manifest.entries {
|
||||||
entry.encryption = None;
|
entry.encryption = None;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue