1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

share login with attachments

This commit is contained in:
Kyle Spearrin
2017-07-10 14:30:12 -04:00
parent fbc189544b
commit f8c749bab5
9 changed files with 264 additions and 48 deletions

View File

@ -48,7 +48,7 @@ namespace Bit.Core.Models.Api
});
}
public Cipher ToCipher(Cipher existingCipher)
public virtual Cipher ToCipher(Cipher existingCipher)
{
switch(existingCipher.Type)
{
@ -64,12 +64,35 @@ namespace Bit.Core.Models.Api
}
}
public class CipherAttachmentRequestModel : CipherRequestModel
{
public Dictionary<string, string> Attachments { get; set; }
public override Cipher ToCipher(Cipher existingCipher)
{
base.ToCipher(existingCipher);
var attachments = existingCipher.GetAttachments();
if((Attachments?.Count ?? 0) > 0 && (attachments?.Count ?? 0) > 0)
{
foreach(var attachment in existingCipher.GetAttachments().Where(a => Attachments.ContainsKey(a.Key)))
{
attachment.Value.FileName = Attachments[attachment.Key];
}
existingCipher.SetAttachments(attachments);
}
return existingCipher;
}
}
public class CipherShareRequestModel : IValidatableObject
{
[Required]
public IEnumerable<string> CollectionIds { get; set; }
[Required]
public CipherRequestModel Cipher { get; set; }
public CipherAttachmentRequestModel Cipher { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{