Address PR #310 review feedback on the public profile page

This commit is contained in:
Aaron Po
2026-09-13 01:05:01 -04:00
parent 81717eddbf
commit 132f93cc87
12 changed files with 127 additions and 32 deletions

View File

@@ -1,5 +1,6 @@
using Domain.Entities;
using Domain.Exceptions;
using Features.Users.Dtos;
using Features.Users.Queries.GetAllUsers;
using Features.Users.Queries.GetUserById;
using MediatR;
@@ -37,4 +38,19 @@ public class UserController(IMediator mediator) : ControllerBase
UserAccount user = await mediator.Send(new GetUserByIdQuery(id));
return Ok(user);
}
/// <summary>Gets the public profile for the user account with the given ID.</summary>
/// <remarks>
/// Exposes only the fields that are safe to show on an unauthenticated, public profile page;
/// unlike <see cref="GetById"/>, this never returns <c>Email</c> or <c>DateOfBirth</c>.
/// </remarks>
/// <exception cref="NotFoundException">
/// Thrown when no user account exists with the given ID, resulting in a 404 response.
/// </exception>
[HttpGet("{id:guid}/profile")]
public async Task<ActionResult<PublicUserProfileDto>> GetPublicProfile(Guid id)
{
UserAccount user = await mediator.Send(new GetUserByIdQuery(id));
return Ok(user.ToPublicProfileDto());
}
}