mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
share service setup
This commit is contained in:
@ -16,13 +16,16 @@ namespace Bit.Api.Controllers
|
||||
{
|
||||
private readonly IShareRepository _shareRepository;
|
||||
private readonly IUserService _userService;
|
||||
private readonly ICipherService _cipherService;
|
||||
|
||||
public SharesController(
|
||||
IShareRepository shareRepository,
|
||||
IUserService userService)
|
||||
IUserService userService,
|
||||
ICipherService cipherService)
|
||||
{
|
||||
_shareRepository = shareRepository;
|
||||
_userService = userService;
|
||||
_cipherService = cipherService;
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
@ -42,7 +45,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<ShareResponseModel> Post([FromBody]ShareRequestModel model)
|
||||
{
|
||||
var share = model.ToShare(_userService.GetProperUserId(User).Value);
|
||||
await _shareRepository.CreateAsync(share);
|
||||
await _cipherService.ShareAsync(share, model.Email);
|
||||
|
||||
var response = new ShareResponseModel(share);
|
||||
return response;
|
||||
|
@ -8,8 +8,7 @@ namespace Bit.Api.Models
|
||||
public class ShareRequestModel
|
||||
{
|
||||
[Required]
|
||||
[StringLength(36)]
|
||||
public string UserId { get; set; }
|
||||
public string Email { get; set; }
|
||||
[Required]
|
||||
[StringLength(36)]
|
||||
public string CipherId { get; set; }
|
||||
@ -25,7 +24,6 @@ namespace Bit.Api.Models
|
||||
|
||||
public Share ToShare(Share existingShare)
|
||||
{
|
||||
existingShare.UserId = new Guid(UserId);
|
||||
existingShare.CipherId = new Guid(CipherId);
|
||||
existingShare.Key = Key;
|
||||
|
||||
|
Reference in New Issue
Block a user