summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathijs van Veluw <[email protected]>2024-09-18 18:57:08 +0200
committerGitHub <[email protected]>2024-09-18 18:57:08 +0200
commit1bf85201e728f9d60d688b846203c1ed45e575ab (patch)
tree358d9ba9bea8b9827abb08a09e8d6b2737844640
parent6ceed9284d16ba11cae4515d6ab666225725cb99 (diff)
downloadvaultwarden-1bf85201e728f9d60d688b846203c1ed45e575ab.tar.gz
vaultwarden-1bf85201e728f9d60d688b846203c1ed45e575ab.zip
Fix Pw History null dates (#4966)
It seemed to have been possible to have `null` date values. This PR fixes this by setting the epoch start date if either the date does not exists or is not a string. This should solve sync issues with the new native mobile clients. Fixes https://github.com/dani-garcia/vaultwarden/pull/4932#issuecomment-2357581292 Signed-off-by: BlackDex <[email protected]>
-rw-r--r--src/db/models/cipher.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/db/models/cipher.rs b/src/db/models/cipher.rs
index 1c6e499d..d0a95d3c 100644
--- a/src/db/models/cipher.rs
+++ b/src/db/models/cipher.rs
@@ -190,11 +190,20 @@ impl Cipher {
.map(|d| {
// Check every password history item if they are valid and return it.
// If a password field has the type `null` skip it, it breaks newer Bitwarden clients
+ // A second check is done to verify the lastUsedDate exists and is a string, if not the epoch start time will be used
d.into_iter()
.filter_map(|d| match d.data.get("password") {
Some(p) if p.is_string() => Some(d.data),
_ => None,
})
+ .map(|d| match d.get("lastUsedDate") {
+ Some(l) if l.is_string() => d,
+ _ => {
+ let mut d = d;
+ d["lastUsedDate"] = json!("1970-01-01T00:00:00.000Z");
+ d
+ }
+ })
.collect()
})
.unwrap_or_default();