diff options
author | Mathijs van Veluw <[email protected]> | 2023-11-05 21:44:29 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2023-11-05 21:44:29 +0100 |
commit | cec1e87679cfd0e2f0bce9b7dc3256dbbd2effa8 (patch) | |
tree | 9259b828b6c5f13539d52783a91cfbb4e129cfc1 | |
parent | 512b3b9b7cdea6ba369f708fcce583ee81dbccda (diff) | |
download | vaultwarden-cec1e87679cfd0e2f0bce9b7dc3256dbbd2effa8.tar.gz vaultwarden-cec1e87679cfd0e2f0bce9b7dc3256dbbd2effa8.zip |
Fix importing Bitwarden exports (#4030)1.30.0
When importing Bitwarden JSON exports, these would fail because the last
modification date was also imported and caused our out-off-sync check to
kick-in. This PR fixes this by checking if we are doing an import, and
skip this check.
Fixes #4005
-rw-r--r-- | src/api/core/ciphers.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs index 733ae7b9..dc3f4dc7 100644 --- a/src/api/core/ciphers.rs +++ b/src/api/core/ciphers.rs @@ -359,14 +359,17 @@ pub async fn update_cipher_from_data( enforce_personal_ownership_policy(Some(&data), headers, conn).await?; // Check that the client isn't updating an existing cipher with stale data. - if let Some(dt) = data.LastKnownRevisionDate { - match NaiveDateTime::parse_from_str(&dt, "%+") { - // ISO 8601 format - Err(err) => warn!("Error parsing LastKnownRevisionDate '{}': {}", dt, err), - Ok(dt) if cipher.updated_at.signed_duration_since(dt).num_seconds() > 1 => { - err!("The client copy of this cipher is out of date. Resync the client and try again.") + // And only perform this check when not importing ciphers, else the date/time check will fail. + if ut != UpdateType::None { + if let Some(dt) = data.LastKnownRevisionDate { + match NaiveDateTime::parse_from_str(&dt, "%+") { + // ISO 8601 format + Err(err) => warn!("Error parsing LastKnownRevisionDate '{}': {}", dt, err), + Ok(dt) if cipher.updated_at.signed_duration_since(dt).num_seconds() > 1 => { + err!("The client copy of this cipher is out of date. Resync the client and try again.") + } + Ok(_) => (), } - Ok(_) => (), } } |