1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-20 02:48:03 -05:00

Switch away from primary constructor

This commit is contained in:
Bernd Schoolmann 2025-06-12 17:03:27 +02:00
parent 4568eddabd
commit 354320a88c
No known key found for this signature in database

View File

@ -10,10 +10,17 @@ namespace Bit.Api.KeyManagement.Controllers;
[Route("users")] [Route("users")]
[Authorize("Application")] [Authorize("Application")]
public class UsersController( public class UsersController : Controller
IUserRepository _userRepository,
IUserAccountKeysQuery _userAccountKeysQuery) : Controller
{ {
private readonly IUserRepository _userRepository;
private readonly IUserAccountKeysQuery _userAccountKeysQuery;
public UsersController(IUserRepository userRepository, IUserAccountKeysQuery userAccountKeysQuery)
{
_userRepository = userRepository;
_userAccountKeysQuery = userAccountKeysQuery;
}
[HttpGet("{id}/public-key")] [HttpGet("{id}/public-key")]
public async Task<UserKeyResponseModel> GetPublicKeyAsync(string id) public async Task<UserKeyResponseModel> GetPublicKeyAsync(string id)
{ {
@ -23,7 +30,7 @@ public class UsersController(
} }
[HttpGet("{id}/keys")] [HttpGet("{id}/keys")]
public async Task<PublicKeysResponseModel> GetAccountKeysAsync([FromRoute]Guid id) public async Task<PublicKeysResponseModel> GetAccountKeysAsync([FromRoute] Guid id)
{ {
var user = await _userRepository.GetByIdAsync(id) ?? throw new NotFoundException(); var user = await _userRepository.GetByIdAsync(id) ?? throw new NotFoundException();
var accountKeys = await _userAccountKeysQuery.Run(user) ?? throw new NotFoundException("User account keys not found."); var accountKeys = await _userAccountKeysQuery.Run(user) ?? throw new NotFoundException("User account keys not found.");