prompt user for encryption passkey if not provided

This commit is contained in:
Carson McManus 2021-08-17 19:20:57 -04:00
parent e1f86d3750
commit d3cdc309ed

View file

@ -192,7 +192,9 @@ fn main() {
accountmanager::ManifestAccountLoadError::MissingPasskey accountmanager::ManifestAccountLoadError::MissingPasskey
| accountmanager::ManifestAccountLoadError::DecryptionFailed, | accountmanager::ManifestAccountLoadError::DecryptionFailed,
) => { ) => {
error!("Incorrect passkey"); if passkey.is_some() {
error!("Incorrect passkey");
}
passkey = rpassword::prompt_password_stdout("Enter encryption passkey: ").ok(); passkey = rpassword::prompt_password_stdout("Enter encryption passkey: ").ok();
} }
Err(e) => { Err(e) => {
@ -313,6 +315,16 @@ fn main() {
manifest.save(&passkey).expect("Failed to save manifest."); manifest.save(&passkey).expect("Failed to save manifest.");
return; return;
} else if matches.is_present("encrypt") { } else if matches.is_present("encrypt") {
if passkey.is_none() {
loop {
passkey = rpassword::prompt_password_stdout("Enter encryption passkey: ").ok();
let passkey_confirm = rpassword::prompt_password_stdout("Confirm encryption passkey: ").ok();
if passkey == passkey_confirm {
break;
}
error!("Passkeys do not match, try again.");
}
}
for entry in &mut manifest.entries { for entry in &mut manifest.entries {
entry.encryption = Some(accountmanager::EntryEncryptionParams::generate()); entry.encryption = Some(accountmanager::EntryEncryptionParams::generate());
} }