mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
cipher details with subvaults api
This commit is contained in:
@ -45,8 +45,8 @@ namespace Bit.Core.Models.Api
|
||||
public class CipherDetailsResponseModel : CipherResponseModel
|
||||
{
|
||||
public CipherDetailsResponseModel(CipherDetails cipher,
|
||||
IDictionary<Guid, IGrouping<Guid, SubvaultCipher>> subvaultCiphers)
|
||||
: base(cipher, "cipherDetails")
|
||||
IDictionary<Guid, IGrouping<Guid, SubvaultCipher>> subvaultCiphers, string obj = "cipherDetails")
|
||||
: base(cipher, obj)
|
||||
{
|
||||
if(subvaultCiphers.ContainsKey(cipher.Id))
|
||||
{
|
||||
@ -58,6 +58,24 @@ namespace Bit.Core.Models.Api
|
||||
}
|
||||
}
|
||||
|
||||
public CipherDetailsResponseModel(CipherDetails cipher, IEnumerable<SubvaultCipher> subvaultCiphers,
|
||||
string obj = "cipherDetails")
|
||||
: base(cipher, obj)
|
||||
{
|
||||
SubvaultIds = subvaultCiphers.Select(s => s.SubvaultId);
|
||||
}
|
||||
|
||||
public IEnumerable<Guid> SubvaultIds { get; set; }
|
||||
}
|
||||
|
||||
public class CipherFullDetailsResponseModel : CipherDetailsResponseModel
|
||||
{
|
||||
public CipherFullDetailsResponseModel(CipherFullDetails cipher, IEnumerable<SubvaultCipher> subvaultCiphers)
|
||||
: base(cipher, subvaultCiphers, "cipherFullDetails")
|
||||
{
|
||||
Edit = cipher.Edit;
|
||||
}
|
||||
|
||||
public bool Edit { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,6 @@ namespace Bit.Core.Repositories
|
||||
public interface ISubvaultCipherRepository
|
||||
{
|
||||
Task<ICollection<SubvaultCipher>> GetManyByUserIdAsync(Guid userId);
|
||||
Task<ICollection<SubvaultCipher>> GetManyByUserIdCipherIdAsync(Guid userId, Guid cipherId);
|
||||
}
|
||||
}
|
||||
|
@ -31,5 +31,18 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
return results.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<SubvaultCipher>> GetManyByUserIdCipherIdAsync(Guid userId, Guid cipherId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<SubvaultCipher>(
|
||||
$"[dbo].[SubvaultCipher_ReadByUserIdCipherId]",
|
||||
new { UserId = userId, CipherId = cipherId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user