mirror of
https://github.com/bitwarden/server
synced 2025-12-20 02:03:46 +00:00
refactor api models for other cipher types
This commit is contained in:
@@ -24,21 +24,30 @@ namespace Bit.Core.Models.Api
|
||||
public string Name { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(10000)]
|
||||
public string Notes { get; set; }
|
||||
public IEnumerable<FieldDataModel> Fields { get; set; }
|
||||
public Dictionary<string, string> Attachments { get; set; }
|
||||
|
||||
public LoginType Login { get; set; }
|
||||
public CardType Card { get; set; }
|
||||
public SecureNoteType SecureNote { get; set; }
|
||||
|
||||
[Obsolete("Use Login property")]
|
||||
[EncryptedString]
|
||||
[StringLength(10000)]
|
||||
public string Uri { get; set; }
|
||||
[Obsolete("Use Login property")]
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Username { get; set; }
|
||||
[Obsolete("Use Login property")]
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Password { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(10000)]
|
||||
public string Notes { get; set; }
|
||||
[Obsolete("Use Login property")]
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Totp { get; set; }
|
||||
public IEnumerable<FieldDataModel> Fields { get; set; }
|
||||
public Dictionary<string, string> Attachments { get; set; }
|
||||
|
||||
public CipherDetails ToCipherDetails(Guid userId)
|
||||
{
|
||||
@@ -69,6 +78,14 @@ namespace Bit.Core.Models.Api
|
||||
existingCipher.Data = JsonConvert.SerializeObject(new LoginDataModel(this),
|
||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
break;
|
||||
case CipherType.Card:
|
||||
existingCipher.Data = JsonConvert.SerializeObject(new CardDataModel(this),
|
||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
break;
|
||||
case CipherType.SecureNote:
|
||||
existingCipher.Data = JsonConvert.SerializeObject(new SecureNoteDataModel(this),
|
||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
||||
}
|
||||
@@ -116,6 +133,49 @@ namespace Bit.Core.Models.Api
|
||||
OrganizationId = new Guid(OrganizationId)
|
||||
});
|
||||
}
|
||||
|
||||
public class LoginType
|
||||
{
|
||||
[EncryptedString]
|
||||
[StringLength(10000)]
|
||||
public string Uri { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Username { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Password { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Totp { get; set; }
|
||||
}
|
||||
|
||||
public class CardType
|
||||
{
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string CardholderName { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Brand { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Number { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string ExpMonth { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string ExpYear { get; set; }
|
||||
[EncryptedString]
|
||||
[StringLength(1000)]
|
||||
public string Code { get; set; }
|
||||
}
|
||||
|
||||
public class SecureNoteType
|
||||
{
|
||||
public Enums.SecureNoteType Type { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class CipherWithIdRequestModel : CipherRequestModel
|
||||
|
||||
Reference in New Issue
Block a user