mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-08-02 00:59:08 +00:00
Fix fields and password history
This commit is contained in:
parent
ccdcbc89ce
commit
8daa3593b1
1 changed files with 18 additions and 10 deletions
|
@ -150,18 +150,26 @@ impl Cipher {
|
||||||
(false, false)
|
(false, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
let fields_json = self
|
let fields_json: Vec<_> = self
|
||||||
.fields
|
.fields
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|s| serde_json::from_str::<LowerCase<Value>>(s).ok())
|
.and_then(|s| {
|
||||||
.unwrap_or_default()
|
serde_json::from_str::<Vec<LowerCase<Value>>>(s)
|
||||||
.data;
|
.inspect_err(|e| warn!("Error parsing fields {:?}", e))
|
||||||
let password_history_json = self
|
.ok()
|
||||||
|
})
|
||||||
|
.map(|d| d.into_iter().map(|d| d.data).collect())
|
||||||
|
.unwrap_or_default();
|
||||||
|
let password_history_json: Vec<_> = self
|
||||||
.password_history
|
.password_history
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|s| serde_json::from_str::<LowerCase<Value>>(s).ok())
|
.and_then(|s| {
|
||||||
.unwrap_or_default()
|
serde_json::from_str::<Vec<LowerCase<Value>>>(s)
|
||||||
.data;
|
.inspect_err(|e| warn!("Error parsing password history {:?}", e))
|
||||||
|
.ok()
|
||||||
|
})
|
||||||
|
.map(|d| d.into_iter().map(|d| d.data).collect())
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
// Get the type_data or a default to an empty json object '{}'.
|
// Get the type_data or a default to an empty json object '{}'.
|
||||||
// If not passing an empty object, mobile clients will crash.
|
// If not passing an empty object, mobile clients will crash.
|
||||||
|
@ -186,10 +194,10 @@ impl Cipher {
|
||||||
|
|
||||||
// NOTE: This was marked as *Backwards Compatibility Code*, but as of January 2021 this is still being used by upstream
|
// NOTE: This was marked as *Backwards Compatibility Code*, but as of January 2021 this is still being used by upstream
|
||||||
// data_json should always contain the following keys with every atype
|
// data_json should always contain the following keys with every atype
|
||||||
data_json["fields"] = fields_json.clone();
|
data_json["fields"] = Value::Array(fields_json.clone());
|
||||||
data_json["name"] = json!(self.name);
|
data_json["name"] = json!(self.name);
|
||||||
data_json["notes"] = json!(self.notes);
|
data_json["notes"] = json!(self.notes);
|
||||||
data_json["passwordHistory"] = password_history_json.clone();
|
data_json["passwordHistory"] = Value::Array(password_history_json.clone());
|
||||||
|
|
||||||
let collection_ids = if let Some(cipher_sync_data) = cipher_sync_data {
|
let collection_ids = if let Some(cipher_sync_data) = cipher_sync_data {
|
||||||
if let Some(cipher_collections) = cipher_sync_data.cipher_collections.get(&self.uuid) {
|
if let Some(cipher_collections) = cipher_sync_data.cipher_collections.get(&self.uuid) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue