Added user management endpoints

This commit is contained in:
2026-10-10 10:12:13 +02:00
parent 1ebd83a2f4
commit 2ee7a49122
19 changed files with 688 additions and 40 deletions
@@ -1,6 +1,35 @@
namespace PostFundManagement.Api.Endpoints.Users;
using PostFundManagement.Application.Abstractions.Services;
using PostFundManagement.Application.Extensions;
using PostFundManagement.Domain.Abstractions;
using PostFundManagement.Domain.Errors;
using PostFundManagement.Domain.Extensions;
public class DeleteUserClaimEndpoint
namespace PostFundManagement.Api.Endpoints.Users;
[ApiVersionTarget(1)]
public sealed class DeleteUserClaimEndpoint : IEndpoint
{
public void Map(IEndpointRouteBuilder builder)
{
builder.MapDelete("api/users/{targetUserId:Guid}/claims/{claimId}", async (string claimId, Guid targetUserId, HttpContext context,
IUserService service, CancellationToken cancellationToken = default) =>
await service.DeleteUserClaimAsync(claimIdHash: claimId, targetUserId: targetUserId, userId: context.GetUserId(), cancellationToken) switch
{
{ IsSuccess: true } => Results.Ok(),
var r when r.HasError<IdDecodeError>() => Results.Forbid(),
var r when r.HasError<ValidationError>() => Results.BadRequest(r.Errors.ToProblems()),
var r when r.HasError<NotFoundError>() => Results.NotFound(r.Errors.ToProblems()),
var r => Results.InternalServerError(r.Errors.ToProblems()),
})
.WithDescription("Deletes a claim from a user")
.RequireAuthorization(Constants.MainScope)
.WithName(typeof(DeleteUserClaimEndpoint).ToEndpointName())
.MapToApiVersion(new ApiVersion(1))
.Produces(StatusCodes.Status200OK)
.Produces(StatusCodes.Status401Unauthorized)
.Produces<Problems>(StatusCodes.Status404NotFound)
.Produces<Problems>(StatusCodes.Status400BadRequest)
.Produces<Problems>(StatusCodes.Status500InternalServerError)
.WithTags(EndpointTags.Users);
}
}