1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-04 09:33:16 +00:00

add other cipher type support to vault listings

This commit is contained in:
Kyle Spearrin
2017-10-18 21:35:33 -04:00
parent 0020bd0fb7
commit 74ac9cbbbe
10 changed files with 267 additions and 138 deletions

View File

@@ -2,24 +2,51 @@
using System.Collections.Generic;
using Bit.App.Resources;
using System.Linq;
using Bit.App.Enums;
namespace Bit.App.Models.Page
{
public class VaultListPageModel
{
public class Login
public class Cipher
{
public Login(Models.Cipher cipher)
public Cipher(Models.Cipher cipher)
{
Id = cipher.Id;
Shared = !string.IsNullOrWhiteSpace(cipher.OrganizationId);
HasAttachments = cipher.Attachments?.Any() ?? false;
FolderId = cipher.FolderId;
Name = cipher.Name?.Decrypt(cipher.OrganizationId);
Username = cipher.Login?.Username?.Decrypt(cipher.OrganizationId) ?? " ";
Password = new Lazy<string>(() => cipher.Login?.Password?.Decrypt(cipher.OrganizationId));
Uri = new Lazy<string>(() => cipher.Login?.Uri?.Decrypt(cipher.OrganizationId));
Totp = new Lazy<string>(() => cipher.Login?.Totp?.Decrypt(cipher.OrganizationId));
Type = cipher.Type;
switch(cipher.Type)
{
case CipherType.Login:
Username = cipher.Login?.Username?.Decrypt(cipher.OrganizationId) ?? " ";
Password = new Lazy<string>(() => cipher.Login?.Password?.Decrypt(cipher.OrganizationId));
Uri = new Lazy<string>(() => cipher.Login?.Uri?.Decrypt(cipher.OrganizationId));
Totp = new Lazy<string>(() => cipher.Login?.Totp?.Decrypt(cipher.OrganizationId));
Subtitle = Username;
break;
case CipherType.SecureNote:
Subtitle = " ";
break;
case CipherType.Card:
var cardNumber = cipher.Card?.Number?.Decrypt(cipher.OrganizationId) ?? " ";
var cardBrand = cipher.Card?.Brand?.Decrypt(cipher.OrganizationId) ?? " ";
CardCode = new Lazy<string>(() => cipher.Card?.Code?.Decrypt(cipher.OrganizationId));
Subtitle = $"{cardBrand}, *{cardNumber}";
break;
case CipherType.Identity:
var firstName = cipher.Identity?.FirstName?.Decrypt(cipher.OrganizationId) ?? " ";
var lastName = cipher.Identity?.LastName?.Decrypt(cipher.OrganizationId) ?? " ";
Subtitle = $"{firstName} {lastName}";
break;
default:
break;
}
}
public string Id { get; set; }
@@ -27,16 +54,24 @@ namespace Bit.App.Models.Page
public bool HasAttachments { get; set; }
public string FolderId { get; set; }
public string Name { get; set; }
public string Subtitle { get; set; }
public CipherType Type { get; set; }
// Login metadata
public string Username { get; set; }
public Lazy<string> Password { get; set; }
public Lazy<string> Uri { get; set; }
public Lazy<string> Totp { get; set; }
// Login metadata
public string CardNumber { get; set; }
public Lazy<string> CardCode { get; set; }
}
public class AutofillLogin : Login
public class AutofillCipher : Cipher
{
public AutofillLogin(Models.Cipher login, bool fuzzy = false)
: base(login)
public AutofillCipher(Models.Cipher cipher, bool fuzzy = false)
: base(cipher)
{
Fuzzy = fuzzy;
}
@@ -44,7 +79,7 @@ namespace Bit.App.Models.Page
public bool Fuzzy { get; set; }
}
public class Folder : List<Login>
public class Folder : List<Cipher>
{
public Folder(Models.Folder folder)
{
@@ -52,18 +87,18 @@ namespace Bit.App.Models.Page
Name = folder.Name?.Decrypt();
}
public Folder(List<Login> logins)
public Folder(List<Cipher> ciphers)
{
AddRange(logins);
AddRange(ciphers);
}
public string Id { get; set; }
public string Name { get; set; } = AppResources.FolderNone;
}
public class AutofillGrouping : List<AutofillLogin>
public class AutofillGrouping : List<AutofillCipher>
{
public AutofillGrouping(List<AutofillLogin> logins, string name)
public AutofillGrouping(List<AutofillCipher> logins, string name)
{
AddRange(logins);
Name = name;