1
0
mirror of https://github.com/bitwarden/server synced 2025-12-25 12:43:14 +00:00

return share information with cipher API response

This commit is contained in:
Kyle Spearrin
2017-02-21 22:52:02 -05:00
parent 8051995cc7
commit 900e71d4dd
11 changed files with 123 additions and 15 deletions

View File

@@ -7,6 +7,7 @@ using DataTableProxy;
using Bit.Core.Domains;
using System.Data;
using Dapper;
using Bit.Core.Models.Data;
namespace Bit.Core.Repositories.SqlServer
{
@@ -31,6 +32,19 @@ namespace Bit.Core.Repositories.SqlServer
return cipher;
}
public async Task<CipherShare> GetShareByIdAsync(Guid id, Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<CipherShare>(
$"[{Schema}].[CipherShare_ReadById]",
new { UserId = userId },
commandType: CommandType.StoredProcedure);
return results.FirstOrDefault(c => c.UserId == userId);
}
}
public async Task<ICollection<Cipher>> GetManyByUserIdAsync(Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))
@@ -44,6 +58,19 @@ namespace Bit.Core.Repositories.SqlServer
}
}
public async Task<ICollection<CipherShare>> GetManyShareByUserIdAsync(Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<CipherShare>(
$"[{Schema}].[CipherShare_ReadByUserId]",
new { UserId = userId },
commandType: CommandType.StoredProcedure);
return results.ToList();
}
}
public async Task<ICollection<Cipher>> GetManyByTypeAndUserIdAsync(Enums.CipherType type, Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))