mirror of
https://github.com/bitwarden/server.git
synced 2026-02-13 20:33:20 +08:00
added identity cipher type
This commit is contained in:
80
src/Core/Models/Api/IdentityDataModel.cs
Normal file
80
src/Core/Models/Api/IdentityDataModel.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Table;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class IdentityDataModel : CipherDataModel
|
||||
{
|
||||
public IdentityDataModel() { }
|
||||
|
||||
public IdentityDataModel(CipherRequestModel cipher)
|
||||
{
|
||||
Name = cipher.Name;
|
||||
Notes = cipher.Notes;
|
||||
Fields = cipher.Fields;
|
||||
|
||||
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.City;
|
||||
PostalCode = cipher.Identity.PostalCode;
|
||||
Country = cipher.Identity.Country;
|
||||
Company = cipher.Identity.Company;
|
||||
Email = cipher.Identity.Email;
|
||||
Phone = cipher.Identity.Phone;
|
||||
SSN = cipher.Identity.SSN;
|
||||
}
|
||||
|
||||
public IdentityDataModel(Cipher cipher)
|
||||
{
|
||||
if(cipher.Type != Enums.CipherType.Identity)
|
||||
{
|
||||
throw new ArgumentException("Cipher is not correct type.");
|
||||
}
|
||||
|
||||
var data = JsonConvert.DeserializeObject<IdentityDataModel>(cipher.Data);
|
||||
|
||||
Name = data.Name;
|
||||
Notes = data.Notes;
|
||||
Fields = data.Fields;
|
||||
|
||||
Title = data.Title;
|
||||
FirstName = data.FirstName;
|
||||
MiddleName = data.MiddleName;
|
||||
LastName = data.LastName;
|
||||
Address1 = data.Address1;
|
||||
Address2 = data.Address2;
|
||||
Address3 = data.Address3;
|
||||
City = data.City;
|
||||
State = data.State;
|
||||
PostalCode = data.PostalCode;
|
||||
Country = data.Country;
|
||||
Company = data.Company;
|
||||
Email = data.Email;
|
||||
Phone = data.Phone;
|
||||
SSN = data.SSN;
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user