aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLionel Flandrin <lfg@svkt.eu>2021-04-01 18:12:08 +0100
committerLionel Flandrin <lfg@svkt.eu>2021-04-01 18:13:00 +0100
commit1d7064f0f9751290ea4113b77f9cc55cf1743ab5 (patch)
treee80f64e7e1e067fa7e8a17f26522f21af73ddd48
parent9e77724efff281f0fe6d05440ad65c5ab561f380 (diff)
downloadrbw-1d7064f0f9751290ea4113b77f9cc55cf1743ab5.tar.gz
rbw-1d7064f0f9751290ea4113b77f9cc55cf1743ab5.zip
Don't generate a password history entry for empty passwords
Fixes #52
-rw-r--r--src/bin/rbw/commands.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index 2da06a2..1ceb409 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -850,14 +850,20 @@ pub fn edit(
} => (username, password, uris, totp),
_ => unreachable!(),
};
- let new_history_entry = rbw::db::HistoryEntry {
- last_used_date: format!(
- "{}",
- humantime::format_rfc3339(std::time::SystemTime::now())
- ),
- password: entry_password.clone().unwrap_or_else(String::new),
- };
- history.insert(0, new_history_entry);
+
+ if let Some(prev_password) = entry_password.clone() {
+ let new_history_entry = rbw::db::HistoryEntry {
+ last_used_date: format!(
+ "{}",
+ humantime::format_rfc3339(
+ std::time::SystemTime::now()
+ )
+ ),
+ password: prev_password,
+ };
+ history.insert(0, new_history_entry);
+ }
+
let data = rbw::db::EntryData::Login {
username: entry_username.clone(),
password,