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:
@ -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(
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user