1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-11 22:03:27 +00:00

refactor for cipher model changes and multi-uris

This commit is contained in:
Kyle Spearrin
2018-03-05 17:18:18 -05:00
parent 1f21a2ecc7
commit 83fd19784a
32 changed files with 491 additions and 223 deletions

View File

@@ -1,4 +1,8 @@
using Bit.App.Models.Data;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Bit.App.Models
{
@@ -8,13 +12,27 @@ namespace Bit.App.Models
public Login(CipherData data)
{
Uri = data.Uri != null ? new CipherString(data.Uri) : null;
Username = data.Username != null ? new CipherString(data.Username) : null;
Password = data.Password != null ? new CipherString(data.Password) : null;
Totp = data.Totp != null ? new CipherString(data.Totp) : null;
LoginDataModel deserializedData;
if(data.Login != null)
{
deserializedData = JsonConvert.DeserializeObject<LoginDataModel>(data.Login);
}
else if(data.Data != null)
{
deserializedData = JsonConvert.DeserializeObject<LoginDataModel>(data.Data);
}
else
{
throw new ArgumentNullException(nameof(data.Identity));
}
Username = deserializedData.Username != null ? new CipherString(deserializedData.Username) : null;
Password = deserializedData.Password != null ? new CipherString(deserializedData.Password) : null;
Totp = deserializedData.Totp != null ? new CipherString(deserializedData.Totp) : null;
Uris = deserializedData.Uris?.Select(u => new LoginUri(u));
}
public CipherString Uri { get; set; }
public IEnumerable<LoginUri> Uris { get; set; }
public CipherString Username { get; set; }
public CipherString Password { get; set; }
public CipherString Totp { get; set; }