using BuildFlow.Platform.Application.Auth.Commands; using MediatR; namespace BuildFlow.Host.Endpoints.Platform.Auth; /// /// 登出接口:撤销 refresh token 并清除 jwt Cookie。 /// 前端通过 baseRequestClient 调用(withCredentials: true 发送 Cookie)。 /// public class LogoutEndpoint(IMediator mediator) : EndpointWithoutRequest { public override void Configure() { Post("/auth/logout"); AllowAnonymous(); } public override async Task HandleAsync(CancellationToken ct) { // 从 Cookie 中读取 refresh token var refreshToken = HttpContext.Request.Cookies["jwt"]; if (!string.IsNullOrEmpty(refreshToken)) { await mediator.Send(new LogoutCommand(refreshToken), ct); } // 清除 Cookie HttpContext.Response.Cookies.Delete("jwt"); await Send.OkAsync(string.Empty, ct); } }