From d85a4b97325020b7efe1a6cdbd55025c6408cec9 Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期五, 25 十月 2024 10:12:06 +0800 Subject: [PATCH] 更新 --- WIDESEAWCS_Server/WIDESEAWCS_Core/Middlewares/SwaggerAuthMiddleware.cs | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Core/Middlewares/SwaggerAuthMiddleware.cs b/WIDESEAWCS_Server/WIDESEAWCS_Core/Middlewares/SwaggerAuthMiddleware.cs index a0bb08b..284ace1 100644 --- a/WIDESEAWCS_Server/WIDESEAWCS_Core/Middlewares/SwaggerAuthMiddleware.cs +++ b/WIDESEAWCS_Server/WIDESEAWCS_Core/Middlewares/SwaggerAuthMiddleware.cs @@ -6,6 +6,7 @@ using System.Net; using System.Text; using System.Threading.Tasks; +using WIDESEAWCS_Core.Extensions; namespace WIDESEAWCS_Core.Middlewares { @@ -22,7 +23,7 @@ public async Task InvokeAsync(HttpContext context) { // 涔熷彲浠ユ牴鎹槸鍚︽槸鏈湴鍋氬垽鏂� IsLocalRequest - if (context.Request.Path.Value.ToLower().Contains("index.html")) + if (context.Request.Path.Value?.ToLower().Contains("index.html") ?? false) { // 鍒ゆ柇鏉冮檺鏄惁姝g‘ if (IsAuthorized(context)) @@ -32,7 +33,7 @@ } // 鏃犳潈闄愶紝璺宠浆swagger鐧诲綍椤� - context.Response.Redirect("/swg-login.html"); + context.RedirectSwaggerLogin(); } else { @@ -44,7 +45,7 @@ { // 浣跨敤session妯″紡 // 鍙互浣跨敤鍏朵粬鐨� - return context.Session.GetString("swagger-code") == "success"; + return context.IsSuccessSwagger(); } /// <summary> @@ -59,7 +60,7 @@ { return true; } - if (context.Connection.RemoteIpAddress.Equals(context.Connection.LocalIpAddress)) + if (context.Connection.RemoteIpAddress?.Equals(context.Connection.LocalIpAddress) ?? false) { return true; } -- Gitblit v1.9.3