From d80b44003ca03cd09bf28278bf2e243581c00332 Mon Sep 17 00:00:00 2001 From: transtrike Date: Wed, 16 Dec 2020 10:23:15 +0200 Subject: Fixed GetById to return only public info --- src/DevHive.Services/Services/UserService.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/DevHive.Services/Services/UserService.cs') diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs index c71209e..06f8b1b 100644 --- a/src/DevHive.Services/Services/UserService.cs +++ b/src/DevHive.Services/Services/UserService.cs @@ -11,7 +11,6 @@ using System.Security.Claims; using Microsoft.IdentityModel.Tokens; using System.Security.Cryptography; using System.Text; -using System.Collections.Immutable; namespace DevHive.Services.Services { @@ -62,14 +61,12 @@ namespace DevHive.Services.Services return new CreatedResult("CreateUser", user); } - public async Task GetUserById(Guid id) + public async Task GetUserById(Guid id) { - User user = await this._userRepository.GetByIdAsync(id); - - if (user == null) - return new NotFoundObjectResult("User does not exist!"); + User user = await this._userRepository.GetByIdAsync(id) + ?? throw new ArgumentException("User does not exist!"); - return new OkObjectResult(user); + return this._userMapper.Map(user); } public async Task UpdateUser(UpdateUserServiceModel updateModel) -- cgit v1.2.3