mirror of
https://github.com/bitwarden/server.git
synced 2025-05-23 04:21:05 -05:00
added identity cipher type
This commit is contained in:
parent
e93b72ae71
commit
7e848e5c55
@ -3,9 +3,10 @@
|
|||||||
public enum CipherType : byte
|
public enum CipherType : byte
|
||||||
{
|
{
|
||||||
// Folder is deprecated
|
// Folder is deprecated
|
||||||
Folder = 0,
|
//Folder = 0,
|
||||||
Login = 1,
|
Login = 1,
|
||||||
SecureNote = 2,
|
SecureNote = 2,
|
||||||
Card = 3
|
Card = 3,
|
||||||
|
Identity = 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
}
|
@ -30,6 +30,7 @@ namespace Bit.Core.Models.Api
|
|||||||
|
|
||||||
public LoginType Login { get; set; }
|
public LoginType Login { get; set; }
|
||||||
public CardType Card { get; set; }
|
public CardType Card { get; set; }
|
||||||
|
public IdentityType Identity { get; set; }
|
||||||
public SecureNoteType SecureNote { get; set; }
|
public SecureNoteType SecureNote { get; set; }
|
||||||
|
|
||||||
public CipherDetails ToCipherDetails(Guid userId)
|
public CipherDetails ToCipherDetails(Guid userId)
|
||||||
@ -65,12 +66,16 @@ namespace Bit.Core.Models.Api
|
|||||||
existingCipher.Data = JsonConvert.SerializeObject(new CardDataModel(this),
|
existingCipher.Data = JsonConvert.SerializeObject(new CardDataModel(this),
|
||||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||||
break;
|
break;
|
||||||
|
case CipherType.Identity:
|
||||||
|
existingCipher.Data = JsonConvert.SerializeObject(new IdentityDataModel(this),
|
||||||
|
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||||
|
break;
|
||||||
case CipherType.SecureNote:
|
case CipherType.SecureNote:
|
||||||
existingCipher.Data = JsonConvert.SerializeObject(new SecureNoteDataModel(this),
|
existingCipher.Data = JsonConvert.SerializeObject(new SecureNoteDataModel(this),
|
||||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
throw new ArgumentException("Unsupported type: " + nameof(Type) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if((Attachments?.Count ?? 0) == 0)
|
if((Attachments?.Count ?? 0) == 0)
|
||||||
@ -155,6 +160,55 @@ namespace Bit.Core.Models.Api
|
|||||||
public string Code { get; set; }
|
public string Code { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class IdentityType
|
||||||
|
{
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string Title { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string MiddleName { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string LastName { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string Address1 { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string Address2 { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string Address3 { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string City { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string State { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string PostalCode { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string Country { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string Company { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string Email { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string Phone { get; set; }
|
||||||
|
[EncryptedString]
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string SSN { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class SecureNoteType
|
public class SecureNoteType
|
||||||
{
|
{
|
||||||
public Enums.SecureNoteType Type { get; set; }
|
public Enums.SecureNoteType Type { get; set; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user