mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-24 16:38:22 +01:00
field and password history domains/views
This commit is contained in:
parent
52a978a59a
commit
d136eee224
49
src/Core/Models/Domain/Field.cs
Normal file
49
src/Core/Models/Domain/Field.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.View;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bit.Core.Models.Domain
|
||||
{
|
||||
public class Field : Domain
|
||||
{
|
||||
private HashSet<string> _map = new HashSet<string>
|
||||
{
|
||||
"Name",
|
||||
"Value"
|
||||
};
|
||||
|
||||
public Field() { }
|
||||
|
||||
public Field(FieldData obj, bool alreadyEncrypted = false)
|
||||
{
|
||||
Type = obj.Type;
|
||||
BuildDomainModel(this, obj, _map, alreadyEncrypted);
|
||||
}
|
||||
|
||||
public CipherString Name { get; set; }
|
||||
public CipherString Value { get; set; }
|
||||
public FieldType Type { get; set; }
|
||||
|
||||
public Task<FieldView> DecryptAsync(string orgId)
|
||||
{
|
||||
return DecryptObjAsync(new FieldView(this), this, _map, orgId);
|
||||
}
|
||||
|
||||
public FieldData ToLoginUriData()
|
||||
{
|
||||
var f = new FieldData();
|
||||
BuildDataModel(this, f, new HashSet<string>
|
||||
{
|
||||
"Name",
|
||||
"Value",
|
||||
"Type"
|
||||
}, new HashSet<string>
|
||||
{
|
||||
"Type"
|
||||
});
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
40
src/Core/Models/Domain/PasswordHistory.cs
Normal file
40
src/Core/Models/Domain/PasswordHistory.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bit.Core.Models.Domain
|
||||
{
|
||||
public class PasswordHistory : Domain
|
||||
{
|
||||
private HashSet<string> _map = new HashSet<string>
|
||||
{
|
||||
"Password"
|
||||
};
|
||||
|
||||
public PasswordHistory() { }
|
||||
|
||||
public PasswordHistory(PasswordHistoryData obj, bool alreadyEncrypted = false)
|
||||
{
|
||||
BuildDomainModel(this, obj, _map, alreadyEncrypted);
|
||||
LastUsedDate = obj.LastUsedDate.GetValueOrDefault();
|
||||
}
|
||||
|
||||
public CipherString Password { get; set; }
|
||||
public DateTime LastUsedDate { get; set; }
|
||||
|
||||
public Task<PasswordHistoryView> DecryptAsync(string orgId)
|
||||
{
|
||||
return DecryptObjAsync(new PasswordHistoryView(this), this, _map, orgId);
|
||||
}
|
||||
|
||||
public PasswordHistoryData ToLoginUriData()
|
||||
{
|
||||
var ph = new PasswordHistoryData();
|
||||
ph.LastUsedDate = LastUsedDate;
|
||||
BuildDataModel(this, ph, _map);
|
||||
return ph;
|
||||
}
|
||||
}
|
||||
}
|
20
src/Core/Models/View/FieldView.cs
Normal file
20
src/Core/Models/View/FieldView.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Domain;
|
||||
|
||||
namespace Bit.Core.Models.View
|
||||
{
|
||||
public class FieldView : View
|
||||
{
|
||||
public FieldView() { }
|
||||
|
||||
public FieldView(Field f)
|
||||
{
|
||||
Type = f.Type;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public FieldType Type { get; set; }
|
||||
public string MaskedValue => Value != null ? "••••••••" : null;
|
||||
}
|
||||
}
|
18
src/Core/Models/View/PasswordHistoryView.cs
Normal file
18
src/Core/Models/View/PasswordHistoryView.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Bit.Core.Models.Domain;
|
||||
using System;
|
||||
|
||||
namespace Bit.Core.Models.View
|
||||
{
|
||||
public class PasswordHistoryView : View
|
||||
{
|
||||
public PasswordHistoryView() { }
|
||||
|
||||
public PasswordHistoryView(PasswordHistory ph)
|
||||
{
|
||||
LastUsedDate = ph.LastUsedDate;
|
||||
}
|
||||
|
||||
public string Password { get; set; }
|
||||
public DateTime? LastUsedDate { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user