@ -5,6 +5,7 @@ using Bit.Core.Exceptions;
@@ -5,6 +5,7 @@ using Bit.Core.Exceptions;
using Bit.Core.Models.Api ;
using Bit.Core.Models.Api.Request ;
using Bit.Core.Models.Api.Response ;
using Bit.Core.Models.Table ;
using Bit.Core.Repositories ;
using Bit.Core.Services ;
using Microsoft.AspNetCore.Authorization ;
@ -60,7 +61,16 @@ namespace Bit.Api.Controllers
@@ -60,7 +61,16 @@ namespace Bit.Api.Controllers
var result = await _ emergencyAccessService . GetAsync ( new Guid ( id ) , userId . Value ) ;
return new EmergencyAccessGranteeDetailsResponseModel ( result ) ;
}
[HttpGet("{id}/policies")]
public async Task < ListResponseModel < PolicyResponseModel > > Policies ( string id )
{
var user = await _ userService . GetUserByPrincipalAsync ( User ) ;
var policies = await _ emergencyAccessService . GetPoliciesAsync ( new Guid ( id ) , user ) ;
var responses = policies . Select < Policy , PolicyResponseModel > ( policy = > new PolicyResponseModel ( policy ) ) ;
return new ListResponseModel < PolicyResponseModel > ( responses ) ;
}
[HttpPut("{id}")]
[HttpPost("{id}")]
public async Task Put ( string id , [ FromBody ] EmergencyAccessUpdateRequestModel model )
@ -136,8 +146,8 @@ namespace Bit.Api.Controllers
@@ -136,8 +146,8 @@ namespace Bit.Api.Controllers
public async Task < EmergencyAccessTakeoverResponseModel > Takeover ( string id )
{
var user = await _ userService . GetUserByPrincipalAsync ( User ) ;
var ( result , grantor , policy ) = await _ emergencyAccessService . TakeoverAsync ( new Guid ( id ) , user ) ;
return new EmergencyAccessTakeoverResponseModel ( result , grantor , policy ) ;
var ( result , grantor ) = await _ emergencyAccessService . TakeoverAsync ( new Guid ( id ) , user ) ;
return new EmergencyAccessTakeoverResponseModel ( result , grantor ) ;
}
[HttpPost("{id}/password")]