Registration.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using MediatR;
  2. using Web.Api.Extensions;
  3. using Web.Api.Common;
  4. namespace Web.Api.Endpoints.Auth;
  5. internal sealed class Registration : IEndpoint
  6. {
  7. public void MapEndpoint(IEndpointRouteBuilder app)
  8. {
  9. // 회원가입 완료 (이메일 인증 후 확인)
  10. app.MapGet("api/auth/registration/{email}", async (
  11. string email,
  12. HttpContext httpContext,
  13. ISender sender,
  14. CancellationToken ct
  15. ) =>
  16. {
  17. var cookieName = "isVerified-Registration";
  18. var cookieValue = httpContext.Request.Cookies[cookieName] ?? string.Empty;
  19. var command = new Application.Features.Api.Auth.Registration.Command(email, cookieValue);
  20. var result = await sender.Send(command, ct);
  21. // 성공 시 쿠키 삭제
  22. if (result.IsSuccess)
  23. {
  24. httpContext.Response.Cookies.Delete(cookieName);
  25. }
  26. return result.Match(
  27. () => ApiResponse.Ok("회원가입이 완료되었습니다."),
  28. CustomResults.Problem
  29. );
  30. })
  31. .WithTags("Auth")
  32. .AllowAnonymous();
  33. }
  34. }