From c92a350ab4b9b2e92e65aa1c655ce0697a32683a Mon Sep 17 00:00:00 2001 From: hjhan Date: Thu, 23 Apr 2026 15:11:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(auth):=20=E4=BF=AE=E5=A4=8D=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E4=BB=A4=E7=89=8C=E4=B8=AD=E9=97=B4=E4=BB=B6=E5=AF=B9?= =?UTF-8?q?AJAX=E8=AF=B7=E6=B1=82=E7=9A=84=E5=93=8D=E5=BA=94=E5=A4=84?= =?UTF-8?q?=E7=90=86=20-=20=E6=B7=BB=E5=8A=A0=E5=AF=B9AJAX=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=9A=84=E6=A3=80=E6=B5=8B=E9=80=BB=E8=BE=91=20-=20?= =?UTF-8?q?=E5=AF=B9AJAX=E8=AF=B7=E6=B1=82=E8=BF=94=E5=9B=9E401=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=A0=81=E8=80=8C=E4=B8=8D=E6=98=AF=E9=87=8D=E5=AE=9A?= =?UTF-8?q?=E5=90=91=20-=20=E4=BF=9D=E6=8C=81=E6=99=AE=E9=80=9A=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=9A=84=E7=99=BB=E5=BD=95=E9=A1=B5=E9=9D=A2=E9=87=8D?= =?UTF-8?q?=E5=AE=9A=E5=90=91=E5=8A=9F=E8=83=BD=20-=20=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E4=BB=A4=E7=89=8C=E9=BB=91=E5=90=8D=E5=8D=95=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E5=90=8E=E6=AD=A3=E7=A1=AE=E5=93=8D=E5=BA=94=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=AE=A2=E6=88=B7=E7=AB=AF=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YLErpWeb/Middleware/RefreshTokenMiddleware.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/YLErpWeb/Middleware/RefreshTokenMiddleware.cs b/YLErpWeb/Middleware/RefreshTokenMiddleware.cs index 36bfe420..60b1b73a 100644 --- a/YLErpWeb/Middleware/RefreshTokenMiddleware.cs +++ b/YLErpWeb/Middleware/RefreshTokenMiddleware.cs @@ -92,7 +92,10 @@ namespace YLErp.Web.Middleware logger.Info($"[中间件] Token在黑名单中,拒绝访问 - JTI: {jti}, Path: {path}"); context.Response.Cookies.Delete("Access-Token"); context.Response.Cookies.Delete("Access-Token-Encrypt"); - context.Response.Redirect("/Account/Login"); + if (context.Request.Headers["X-Requested-With"] == "XMLHttpRequest") + context.Response.StatusCode = 401; + else + context.Response.Redirect("/Account/Login"); return; }