mirror of
https://github.com/bitwarden/mobile
synced 2025-12-17 16:53:26 +00:00
domains and view stubs
This commit is contained in:
@@ -1,15 +1,68 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bit.Core.Models.Domain
|
||||
{
|
||||
public class Login : Domain
|
||||
{
|
||||
public Login() { }
|
||||
|
||||
public Login(LoginData obj, bool alreadyEncrypted = false)
|
||||
{
|
||||
PasswordRevisionDate = obj.PasswordRevisionDate;
|
||||
Uris = obj.Uris?.Select(u => new LoginUri(u, alreadyEncrypted)).ToList();
|
||||
BuildDomainModel(this, obj, new HashSet<string>
|
||||
{
|
||||
"Username",
|
||||
"Password",
|
||||
"Totp"
|
||||
}, alreadyEncrypted);
|
||||
}
|
||||
|
||||
public List<LoginUri> Uris { get; set; }
|
||||
public CipherString Username { get; set; }
|
||||
public CipherString Password { get; set; }
|
||||
public DateTime? PasswordRevisionDate { get; set; }
|
||||
public CipherString Totp { get; set; }
|
||||
|
||||
public async Task<LoginView> DecryptAsync(string orgId)
|
||||
{
|
||||
var view = await DecryptObjAsync(new LoginView(this), this, new HashSet<string>
|
||||
{
|
||||
"Username",
|
||||
"Password",
|
||||
"Totp"
|
||||
}, orgId);
|
||||
if(Uris != null)
|
||||
{
|
||||
view.Uris = new List<LoginUriView>();
|
||||
foreach(var uri in Uris)
|
||||
{
|
||||
view.Uris.Add(await uri.DecryptAsync(orgId));
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
public LoginData ToLoginUriData()
|
||||
{
|
||||
var l = new LoginData();
|
||||
l.PasswordRevisionDate = PasswordRevisionDate;
|
||||
BuildDataModel(this, l, new HashSet<string>
|
||||
{
|
||||
"Username",
|
||||
"Password",
|
||||
"Totp"
|
||||
});
|
||||
if(Uris?.Any() ?? false)
|
||||
{
|
||||
l.Uris = Uris.Select(u => u.ToLoginUriData()).ToList();
|
||||
}
|
||||
return l;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user