mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 17:12:49 -05:00
Move into and read ciphers from org subvaults
This commit is contained in:
@ -4,6 +4,7 @@ using Bit.Core.Utilities;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Enums;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
@ -15,6 +16,8 @@ namespace Bit.Core.Models.Api
|
||||
[StringLength(36)]
|
||||
public string Id { get; set; }
|
||||
[StringLength(36)]
|
||||
public string OrganizationId { get; set; }
|
||||
[StringLength(36)]
|
||||
public string FolderId { get; set; }
|
||||
[Required]
|
||||
[EncryptedString]
|
||||
@ -35,24 +38,35 @@ namespace Bit.Core.Models.Api
|
||||
|
||||
public virtual Cipher ToCipher(Guid userId)
|
||||
{
|
||||
var cipher = new Cipher
|
||||
return ToCipher(new Cipher
|
||||
{
|
||||
Id = new Guid(Id),
|
||||
UserId = userId,
|
||||
//FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : (Guid?)new Guid(FolderId),
|
||||
UserId = string.IsNullOrWhiteSpace(OrganizationId) ? (Guid?)userId : null,
|
||||
Type = Type
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
switch(Type)
|
||||
public Cipher ToCipher(Cipher existingCipher)
|
||||
{
|
||||
existingCipher.OrganizationId = string.IsNullOrWhiteSpace(OrganizationId) ? null : (Guid?)new Guid(OrganizationId);
|
||||
|
||||
switch(existingCipher.Type)
|
||||
{
|
||||
case CipherType.Login:
|
||||
cipher.Data = JsonConvert.SerializeObject(new LoginDataModel(this), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
existingCipher.Data = JsonConvert.SerializeObject(new LoginDataModel(this), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
||||
}
|
||||
|
||||
return cipher;
|
||||
return existingCipher;
|
||||
}
|
||||
}
|
||||
|
||||
public class CipherMoveRequestModel
|
||||
{
|
||||
public IEnumerable<string> SubvaultIds { get; set; }
|
||||
[Required]
|
||||
public CipherRequestModel Cipher { get; set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user