From 2428d64488dcbd260a6f535a447f49b9e23e216a Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 5 Jun 2025 20:34:25 +0200 Subject: [PATCH] Cleanup --- .../Controllers/UsersController.cs | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/Api/KeyManagement/Controllers/UsersController.cs b/src/Api/KeyManagement/Controllers/UsersController.cs index 9eca02624e..9e4079f78a 100644 --- a/src/Api/KeyManagement/Controllers/UsersController.cs +++ b/src/Api/KeyManagement/Controllers/UsersController.cs @@ -18,12 +18,7 @@ public class UsersController( public async Task GetPublicKeyAsync(string id) { var guidId = new Guid(id); - var key = await _userRepository.GetPublicKeyAsync(guidId); - if (key == null) - { - throw new NotFoundException(); - } - + var key = await _userRepository.GetPublicKeyAsync(guidId) ?? throw new NotFoundException(); return new UserKeyResponseModel(guidId, key); } @@ -31,17 +26,8 @@ public class UsersController( public async Task GetAccountKeysAsync(string id) { var guidId = new Guid(id); - var user = await _userRepository.GetByIdAsync(guidId); - if (user == null) - { - throw new NotFoundException(); - } - - var accountKeys = await _userAccountKeysQuery.Run(user); - if (accountKeys == null) - { - throw new NotFoundException("User account keys not found."); - } + var user = await _userRepository.GetByIdAsync(guidId) ?? throw new NotFoundException(); + var accountKeys = await _userAccountKeysQuery.Run(user) ?? throw new NotFoundException("User account keys not found."); return new PublicKeysResponseModel(accountKeys); } }