ResendEmail.cs 906 B

12345678910111213141516171819202122232425262728293031
  1. using MediatR;
  2. using Web.Api.Extensions;
  3. using Web.Api.Common;
  4. using Domain.Entities.EmailVerification.ValueObject;
  5. namespace Web.Api.Endpoints.Auth;
  6. internal sealed class ResendEmail : IEndpoint
  7. {
  8. public sealed record Request(string Email, VerificationType Type);
  9. public void MapEndpoint(IEndpointRouteBuilder app)
  10. {
  11. app.MapPost("api/auth/resend-email", async (
  12. Request request,
  13. ISender sender,
  14. CancellationToken ct
  15. ) =>
  16. {
  17. var command = new Application.Features.Api.Auth.ResendEmail.Command(request.Email, request.Type);
  18. var result = await sender.Send(command, ct);
  19. return result.Match(
  20. () => ApiResponse.Ok("이메일 인증번호 재전송 완료"),
  21. CustomResults.Problem
  22. );
  23. })
  24. .WithTags("Auth")
  25. .AllowAnonymous();
  26. }
  27. }