1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-16 23:27:30 -05:00

refactor for cipher details, folders, favorites

This commit is contained in:
Kyle Spearrin
2017-03-18 11:58:02 -04:00
parent 2b71420818
commit 588f6c7c2c
15 changed files with 139 additions and 138 deletions

View File

@ -8,7 +8,7 @@ namespace Bit.Core.Repositories
{
public interface ICipherRepository : IRepository<Cipher, Guid>
{
Task<Cipher> GetByIdAsync(Guid id, Guid userId);
Task<CipherDetails> GetByIdAsync(Guid id, Guid userId);
Task<ICollection<CipherDetails>> GetManyByUserIdAsync(Guid userId);
Task<ICollection<CipherDetails>> GetManyByTypeAndUserIdAsync(Enums.CipherType type, Guid userId);
Task<Tuple<ICollection<CipherDetails>, ICollection<Guid>>> GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(

View File

@ -21,15 +21,17 @@ namespace Bit.Core.Repositories.SqlServer
: base(connectionString)
{ }
public async Task<Cipher> GetByIdAsync(Guid id, Guid userId)
public async Task<CipherDetails> GetByIdAsync(Guid id, Guid userId)
{
var cipher = await GetByIdAsync(id);
if(cipher == null || cipher.UserId != userId)
using(var connection = new SqlConnection(ConnectionString))
{
return null;
}
var results = await connection.QueryAsync<CipherDetails>(
$"[{Schema}].[CipherDetails_ReadById]",
new { Id = id },
commandType: CommandType.StoredProcedure);
return cipher;
return results.FirstOrDefault(c => c.UserId == userId);
}
}
public async Task<ICollection<CipherDetails>> GetManyByUserIdAsync(Guid userId)