- 将 file 相关端点命名空间从小写改为首字母大写 - 将 im 相关端点命名空间从小写改为首字母大写 - 将 workflow 相关端点命名空间从小写改为首字母大写 - 将 rag 相关端点命名空间从小写改为首字母大写 - 将 platform 相关端点命名空间从小写改为首字母大写 - 保持代码功能不变,仅调整命名空间命名风格一致性
34 lines
940 B
C#
34 lines
940 B
C#
using BuildFlow.Platform.Application.Auth.Commands;
|
||
using MediatR;
|
||
|
||
namespace BuildFlow.Host.Endpoints.Platform.Auth;
|
||
|
||
/// <summary>
|
||
/// 登出接口:撤销 refresh token 并清除 jwt Cookie。
|
||
/// 前端通过 baseRequestClient 调用(withCredentials: true 发送 Cookie)。
|
||
/// </summary>
|
||
public class LogoutEndpoint(IMediator mediator) : EndpointWithoutRequest<string>
|
||
{
|
||
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);
|
||
}
|
||
}
|