Fix cipher changes in extension model

This commit is contained in:
Kyle Spearrin 2017-10-20 16:56:10 -04:00
parent 5a88a66709
commit 8970525861

View file

@ -7,27 +7,27 @@ namespace Bit.iOS.Extension.Models
{ {
public class LoginViewModel public class LoginViewModel
{ {
public LoginViewModel(Cipher login) public LoginViewModel(Cipher cipher)
{ {
Id = login.Id; Id = cipher.Id;
Name = login.Name?.Decrypt(login.OrganizationId); Name = cipher.Name?.Decrypt(cipher.OrganizationId);
Username = login.Username?.Decrypt(login.OrganizationId); Username = cipher.Login?.Username?.Decrypt(cipher.OrganizationId);
Password = login.Password?.Decrypt(login.OrganizationId); Password = cipher.Login?.Password?.Decrypt(cipher.OrganizationId);
Uri = login.Uri?.Decrypt(login.OrganizationId); Uri = cipher.Login?.Uri?.Decrypt(cipher.OrganizationId);
Totp = new Lazy<string>(() => login.Totp?.Decrypt(login.OrganizationId)); Totp = new Lazy<string>(() => cipher.Login?.Totp?.Decrypt(cipher.OrganizationId));
Fields = new Lazy<List<Tuple<string, string>>>(() => Fields = new Lazy<List<Tuple<string, string>>>(() =>
{ {
if(!login.Fields?.Any() ?? true) if(!cipher.Fields?.Any() ?? true)
{ {
return null; return null;
} }
var fields = new List<Tuple<string, string>>(); var fields = new List<Tuple<string, string>>();
foreach(var field in login.Fields) foreach(var field in cipher.Fields)
{ {
fields.Add(new Tuple<string, string>( fields.Add(new Tuple<string, string>(
field.Name?.Decrypt(login.OrganizationId), field.Name?.Decrypt(cipher.OrganizationId),
field.Value?.Decrypt(login.OrganizationId))); field.Value?.Decrypt(cipher.OrganizationId)));
} }
return fields; return fields;
}); });