trim Uri proper from stored json on save

This commit is contained in:
Kyle Spearrin 2018-03-05 23:49:48 -05:00
parent 005b2a4fb6
commit deb1ead4ea
3 changed files with 8 additions and 5 deletions

View File

@ -5,6 +5,7 @@ using Newtonsoft.Json;
using System.Linq; using System.Linq;
using Bit.App.Enums; using Bit.App.Enums;
using Bit.App.Models.Api; using Bit.App.Models.Api;
using Newtonsoft.Json.Linq;
namespace Bit.App.Models.Data namespace Bit.App.Models.Data
{ {
@ -31,8 +32,10 @@ namespace Bit.App.Models.Data
switch(cipher.Type) switch(cipher.Type)
{ {
case CipherType.Login: case CipherType.Login:
var loginData = new LoginDataModel(cipher); var loginObj = JObject.FromObject(new LoginDataModel(cipher),
Login = JsonConvert.SerializeObject(loginData); new JsonSerializer { NullValueHandling = NullValueHandling.Ignore });
loginObj[nameof(LoginDataModel.Uri)]?.Parent?.Remove();
Login = loginObj.ToString(Formatting.None);
break; break;
case CipherType.SecureNote: case CipherType.SecureNote:
var noteData = new SecureNoteDataModel(cipher); var noteData = new SecureNoteDataModel(cipher);

View File

@ -12,7 +12,7 @@ namespace Bit.App.Models.Data
{ {
Name = cipher.Name; Name = cipher.Name;
Notes = cipher.Notes; Notes = cipher.Notes;
Fields = cipher.Fields.Select(f => new FieldDataModel(f)); Fields = cipher.Fields?.Select(f => new FieldDataModel(f));
} }
public string Name { get; set; } public string Name { get; set; }

View File

@ -11,9 +11,9 @@ namespace Bit.App.Models
public Identity(CipherData data) public Identity(CipherData data)
{ {
IdentityDataModel deserializedData; IdentityDataModel deserializedData;
if(data.Card != null) if(data.Identity != null)
{ {
deserializedData = JsonConvert.DeserializeObject<IdentityDataModel>(data.Card); deserializedData = JsonConvert.DeserializeObject<IdentityDataModel>(data.Identity);
} }
else if(data.Data != null) else if(data.Data != null)
{ {