| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System.Security.Claims;
- using Application.Abstractions.Messaging;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.MyPage;
- internal sealed class SnsDisconnect : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapDelete("api/mypage/sns/{provider}", async (
- string provider,
- ClaimsPrincipal user,
- ISender sender,
- CancellationToken ct
- ) => {
- var memberID = user.GetMemberID();
- if (memberID is null)
- {
- return ApiResponse.Fail(StatusCodes.Status401Unauthorized, "Invalid token");
- }
- // path parameter 정규화 — google → Google
- var normalizedProvider = char.ToUpperInvariant(provider[0]) + provider[1..].ToLowerInvariant();
- var command = new Application.Features.Api.MyPage.Sns.Disconnect.Command(
- memberID.Value,
- normalizedProvider
- );
- var result = await sender.Send(command, ct);
- return result.Match(
- data => ApiResponse.Ok(data),
- CustomResults.Problem
- );
- })
- .WithTags("MyPage")
- .RequireAuthorization();
- }
- }
|