UnlinkYouTube.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Security.Claims;
  2. using Application.Abstractions.Messaging;
  3. using Web.Api.Common;
  4. using Web.Api.Extensions;
  5. namespace Web.Api.Endpoints.MyPage;
  6. /// <summary>
  7. /// YouTube 연동 해제 — 회원 본인의 YouTube OAuth 권한과 캐시된 YT 데이터를 즉시 폐기.
  8. /// 회원 탈퇴는 일어나지 않음. YouTube API Services ToS 의 "사용자 데이터 삭제 요청 즉시 처리" 준수.
  9. /// </summary>
  10. internal sealed class UnlinkYouTube : IEndpoint
  11. {
  12. public void MapEndpoint(IEndpointRouteBuilder app)
  13. {
  14. app.MapPost("api/mypage/unlink-youtube", async (
  15. ClaimsPrincipal user,
  16. ISender sender,
  17. CancellationToken ct
  18. ) => {
  19. var memberID = user.GetMemberID();
  20. if (memberID is null)
  21. {
  22. return ApiResponse.Fail(StatusCodes.Status401Unauthorized, "Invalid token");
  23. }
  24. var command = new Application.Features.Api.MyPage.UnlinkYouTube.Command(memberID.Value);
  25. var result = await sender.Send(command, ct);
  26. return result.Match(
  27. () => ApiResponse.Ok(),
  28. CustomResults.Problem
  29. );
  30. })
  31. .WithTags("MyPage")
  32. .WithSummary("YouTube 연동 해제 — OAuth 권한 회수 및 캐시된 YT 데이터 삭제")
  33. .RequireAuthorization();
  34. }
  35. }