From 3b263b4563721d7b5d1cec66de2a68da87fee88c Mon Sep 17 00:00:00 2001 From: xRain Date: Mon, 4 May 2026 23:23:35 +0800 Subject: [PATCH] =?UTF-8?q?/user/info=E4=B8=8D=E5=86=8D=E9=9C=80=E8=A6=81s?= =?UTF-8?q?imapiauth,/auth/check=E5=8E=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/SimApiAuthController.cs | 7 ------- Controllers/SimApiCommonController.cs | 13 +++++-------- SimApiExtensions.cs | 13 ------------- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/Controllers/SimApiAuthController.cs b/Controllers/SimApiAuthController.cs index e13f563..100bb03 100644 --- a/Controllers/SimApiAuthController.cs +++ b/Controllers/SimApiAuthController.cs @@ -9,13 +9,6 @@ using static SimApiError; public class SimApiAuthController(SimApiAuth auth) : SimApiBaseController { - /// - /// 获取已登录用户信息 - /// - /// - [HttpPost, SimApiAuth, SimApiDoc("认证", "获取已登录用户信息")] - public SimApiLoginItem UserInfo() => LoginInfo; - /// /// 退出登陆 /// diff --git a/Controllers/SimApiCommonController.cs b/Controllers/SimApiCommonController.cs index 92bcc41..9390363 100644 --- a/Controllers/SimApiCommonController.cs +++ b/Controllers/SimApiCommonController.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using SimApi.Attributes; +using SimApi.Communications; using SimApi.Helpers; using static SimApi.Helpers.SimApiError; @@ -17,7 +18,7 @@ public class SimApiCommonController : SimApiBaseController [ApiExplorerSettings(IgnoreApi = true)] public void ExceptionHandler(int code) { - SimApiError.Error(code); + Error(code); } @@ -32,13 +33,9 @@ public class SimApiCommonController : SimApiBaseController } /// - /// 检测用户登陆的控制器 + /// 获取已登录用户信息 /// /// - [HttpPost, SimApiAuth, SimApiDoc("认证", "检测登陆")] - public string CheckLogin() - { - ErrorWhenNull(LoginInfo, 401, "未登录"); - return LoginInfo.Id; - } + [HttpPost("/user/info"), SimApiAuth, SimApiDoc("认证", "获取已登录用户信息")] + public SimApiLoginItem UserInfo() => LoginInfo; } \ No newline at end of file diff --git a/SimApiExtensions.cs b/SimApiExtensions.cs index 8f3bc3b..3d485ed 100644 --- a/SimApiExtensions.cs +++ b/SimApiExtensions.cs @@ -426,23 +426,10 @@ public static class SimApiExtensions } } - builder.MapControllerRoute(name: "CheckLogin", pattern: "/auth/check", - defaults: new - { - controller = "SimApiCommon", - action = "CheckLogin" - }); if (options.EnableSimApiAuth) { logger.LogInformation("开始配置SimApiAuth..."); builder.UseMiddleware(); - builder.MapControllerRoute(name: "GetUserInfo", pattern: "/user/info", - defaults: new - { - controller = "SimApiAuth", - action = "UserInfo" - }); - builder.MapControllerRoute(name: "Logout", pattern: "/auth/logout", defaults: new {