mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 16:42:50 -05:00
share api
This commit is contained in:
@ -7,6 +7,7 @@ namespace Bit.Core.Domains
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public Guid SharerUserId { get; set; }
|
||||
public Guid CipherId { get; set; }
|
||||
public string Key { get; set; }
|
||||
public string Permissions { get; set; }
|
||||
|
@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bit.Core.Repositories
|
||||
{
|
||||
public interface IShareRepository : IRepository<Share, Guid>
|
||||
{
|
||||
Task<Share> GetByIdAsync(Guid id, Guid userId);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
@ -12,5 +13,16 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
public ShareRepository(string connectionString)
|
||||
: base(connectionString)
|
||||
{ }
|
||||
|
||||
public async Task<Share> GetByIdAsync(Guid id, Guid userId)
|
||||
{
|
||||
var share = await GetByIdAsync(id);
|
||||
if(share == null || (share.UserId != userId && share.SharerUserId != userId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return share;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user