From deb1ead4eaf118f0efffdfddf1b84ee801b7e821 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 5 Mar 2018 23:49:48 -0500 Subject: [PATCH] trim Uri proper from stored json on save --- src/App/Models/Data/CipherData.cs | 7 +++++-- src/App/Models/Data/CipherData/CipherDataModel.cs | 2 +- src/App/Models/Identity.cs | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/App/Models/Data/CipherData.cs b/src/App/Models/Data/CipherData.cs index 46bd7f9ff..eece1b303 100644 --- a/src/App/Models/Data/CipherData.cs +++ b/src/App/Models/Data/CipherData.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json; using System.Linq; using Bit.App.Enums; using Bit.App.Models.Api; +using Newtonsoft.Json.Linq; namespace Bit.App.Models.Data { @@ -31,8 +32,10 @@ namespace Bit.App.Models.Data switch(cipher.Type) { case CipherType.Login: - var loginData = new LoginDataModel(cipher); - Login = JsonConvert.SerializeObject(loginData); + var loginObj = JObject.FromObject(new LoginDataModel(cipher), + new JsonSerializer { NullValueHandling = NullValueHandling.Ignore }); + loginObj[nameof(LoginDataModel.Uri)]?.Parent?.Remove(); + Login = loginObj.ToString(Formatting.None); break; case CipherType.SecureNote: var noteData = new SecureNoteDataModel(cipher); diff --git a/src/App/Models/Data/CipherData/CipherDataModel.cs b/src/App/Models/Data/CipherData/CipherDataModel.cs index 27a958d7b..1e5c80379 100644 --- a/src/App/Models/Data/CipherData/CipherDataModel.cs +++ b/src/App/Models/Data/CipherData/CipherDataModel.cs @@ -12,7 +12,7 @@ namespace Bit.App.Models.Data { Name = cipher.Name; Notes = cipher.Notes; - Fields = cipher.Fields.Select(f => new FieldDataModel(f)); + Fields = cipher.Fields?.Select(f => new FieldDataModel(f)); } public string Name { get; set; } diff --git a/src/App/Models/Identity.cs b/src/App/Models/Identity.cs index 0383b0dae..72d2ff4fe 100644 --- a/src/App/Models/Identity.cs +++ b/src/App/Models/Identity.cs @@ -11,9 +11,9 @@ namespace Bit.App.Models public Identity(CipherData data) { IdentityDataModel deserializedData; - if(data.Card != null) + if(data.Identity != null) { - deserializedData = JsonConvert.DeserializeObject(data.Card); + deserializedData = JsonConvert.DeserializeObject(data.Identity); } else if(data.Data != null) {