1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-05-29 15:03:57 +00:00

Update dependencies and remove unwraps from Cipher::to_json

This commit is contained in:
Daniel García 2019-06-14 22:51:50 +02:00
parent fff72889f6
commit 76f38621de
No known key found for this signature in database
GPG key ID: FC8A7D14C3CD543A
4 changed files with 198 additions and 170 deletions

View file

@ -77,19 +77,10 @@ impl Cipher {
let attachments = Attachment::find_by_cipher(&self.uuid, conn);
let attachments_json: Vec<Value> = attachments.iter().map(|c| c.to_json(host)).collect();
let fields_json: Value = if let Some(ref fields) = self.fields {
serde_json::from_str(fields).unwrap()
} else {
Value::Null
};
let fields_json = self.fields.as_ref().and_then(|s| serde_json::from_str(s).ok()).unwrap_or(Value::Null);
let password_history_json = self.password_history.as_ref().and_then(|s| serde_json::from_str(s).ok()).unwrap_or(Value::Null);
let password_history_json: Value = if let Some(ref password_history) = self.password_history {
serde_json::from_str(password_history).unwrap()
} else {
Value::Null
};
let mut data_json: Value = serde_json::from_str(&self.data).unwrap();
let mut data_json: Value = serde_json::from_str(&self.data).unwrap_or(Value::Null);
// TODO: ******* Backwards compat start **********
// To remove backwards compatibility, just remove this entire section