mirror of
https://github.com/bitwarden/server.git
synced 2025-07-06 10:32:49 -05:00
add support for multiple uris on login model.
refactor cipher data models.
This commit is contained in:
27
src/Core/Models/Data/CipherCardData.cs
Normal file
27
src/Core/Models/Data/CipherCardData.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
public class CipherCardData : CipherData
|
||||
{
|
||||
public CipherCardData() { }
|
||||
|
||||
public CipherCardData(CipherRequestModel cipher)
|
||||
: base(cipher)
|
||||
{
|
||||
CardholderName = cipher.Card.CardholderName;
|
||||
Brand = cipher.Card.Brand;
|
||||
Number = cipher.Card.Number;
|
||||
ExpMonth = cipher.Card.ExpMonth;
|
||||
ExpYear = cipher.Card.ExpYear;
|
||||
Code = cipher.Card.Code;
|
||||
}
|
||||
|
||||
public string CardholderName { get; set; }
|
||||
public string Brand { get; set; }
|
||||
public string Number { get; set; }
|
||||
public string ExpMonth { get; set; }
|
||||
public string ExpYear { get; set; }
|
||||
public string Code { get; set; }
|
||||
}
|
||||
}
|
22
src/Core/Models/Data/CipherData.cs
Normal file
22
src/Core/Models/Data/CipherData.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
public abstract class CipherData
|
||||
{
|
||||
public CipherData() { }
|
||||
|
||||
public CipherData(CipherRequestModel cipher)
|
||||
{
|
||||
Name = cipher.Name;
|
||||
Notes = cipher.Notes;
|
||||
Fields = cipher.Fields.Select(f => new CipherFieldData(f));
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public IEnumerable<CipherFieldData> Fields { get; set; }
|
||||
}
|
||||
}
|
21
src/Core/Models/Data/CipherFieldData.cs
Normal file
21
src/Core/Models/Data/CipherFieldData.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
public class CipherFieldData
|
||||
{
|
||||
public CipherFieldData() { }
|
||||
|
||||
public CipherFieldData(CipherFieldModel field)
|
||||
{
|
||||
Type = field.Type;
|
||||
Name = field.Name;
|
||||
Value = field.Value;
|
||||
}
|
||||
|
||||
public FieldType Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
51
src/Core/Models/Data/CipherIdentityData.cs
Normal file
51
src/Core/Models/Data/CipherIdentityData.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
public class CipherIdentityData : CipherData
|
||||
{
|
||||
public CipherIdentityData() { }
|
||||
|
||||
public CipherIdentityData(CipherRequestModel cipher)
|
||||
: base(cipher)
|
||||
{
|
||||
Title = cipher.Identity.Title;
|
||||
FirstName = cipher.Identity.FirstName;
|
||||
MiddleName = cipher.Identity.MiddleName;
|
||||
LastName = cipher.Identity.LastName;
|
||||
Address1 = cipher.Identity.Address1;
|
||||
Address2 = cipher.Identity.Address2;
|
||||
Address3 = cipher.Identity.Address3;
|
||||
City = cipher.Identity.City;
|
||||
State = cipher.Identity.State;
|
||||
PostalCode = cipher.Identity.PostalCode;
|
||||
Country = cipher.Identity.Country;
|
||||
Company = cipher.Identity.Company;
|
||||
Email = cipher.Identity.Email;
|
||||
Phone = cipher.Identity.Phone;
|
||||
SSN = cipher.Identity.SSN;
|
||||
Username = cipher.Identity.Username;
|
||||
PassportNumber = cipher.Identity.PassportNumber;
|
||||
LicenseNumber = cipher.Identity.LicenseNumber;
|
||||
}
|
||||
|
||||
public string Title { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string MiddleName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string Address1 { get; set; }
|
||||
public string Address2 { get; set; }
|
||||
public string Address3 { get; set; }
|
||||
public string City { get; set; }
|
||||
public string State { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Country { get; set; }
|
||||
public string Company { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string SSN { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string PassportNumber { get; set; }
|
||||
public string LicenseNumber { get; set; }
|
||||
}
|
||||
}
|
40
src/Core/Models/Data/CipherLoginData.cs
Normal file
40
src/Core/Models/Data/CipherLoginData.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
public class CipherLoginData : CipherData
|
||||
{
|
||||
public CipherLoginData() { }
|
||||
|
||||
public CipherLoginData(CipherRequestModel cipher)
|
||||
: base(cipher)
|
||||
{
|
||||
Uris = cipher.Login.Uris?.Where(u => u != null).Select(u => new LoginDataUriModel(u));
|
||||
Username = cipher.Login.Username;
|
||||
Password = cipher.Login.Password;
|
||||
Totp = cipher.Login.Totp;
|
||||
}
|
||||
|
||||
public IEnumerable<LoginDataUriModel> Uris { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Totp { get; set; }
|
||||
|
||||
public class LoginDataUriModel
|
||||
{
|
||||
public LoginDataUriModel() { }
|
||||
|
||||
public LoginDataUriModel(CipherLoginModel.LoginApiUriModel uri)
|
||||
{
|
||||
Uri = uri.Uri;
|
||||
MatchType = uri.MatchType;
|
||||
}
|
||||
|
||||
public string Uri { get; set; }
|
||||
public UriMatchType MatchType { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
18
src/Core/Models/Data/CipherSecureNoteData.cs
Normal file
18
src/Core/Models/Data/CipherSecureNoteData.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
public class CipherSecureNoteData : CipherData
|
||||
{
|
||||
public CipherSecureNoteData() { }
|
||||
|
||||
public CipherSecureNoteData(CipherRequestModel cipher)
|
||||
: base(cipher)
|
||||
{
|
||||
Type = cipher.SecureNote.Type;
|
||||
}
|
||||
|
||||
public SecureNoteType Type { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user