From 17e4c7e3e7b3ef60d9da6de3b2a39a14a53c38a0 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期三, 12 三月 2025 14:11:33 +0800
Subject: [PATCH] 1

---
 WIDESEAWCS_Server/WIDESEAWCS_Core/Authorization/AuthorizationSetup.cs |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Core/Authorization/AuthorizationSetup.cs b/WIDESEAWCS_Server/WIDESEAWCS_Core/Authorization/AuthorizationSetup.cs
index 11b2c93..a4b64ea 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_Core/Authorization/AuthorizationSetup.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_Core/Authorization/AuthorizationSetup.cs
@@ -5,11 +5,13 @@
 using Microsoft.IdentityModel.Tokens;
 using System;
 using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
 using System.Linq;
 using System.Security.Claims;
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEAWCS_Core.Const;
+using WIDESEAWCS_Core.Extensions;
 using WIDESEAWCS_Core.Helper;
 
 namespace WIDESEAWCS_Core.Authorization
@@ -27,7 +29,7 @@
         public static void AddAuthorizationSetup(this IServiceCollection services)
         {
             if (services == null) throw new ArgumentNullException(nameof(services));
-            
+
             services.AddAuthentication(options =>
             {
                 options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
@@ -57,7 +59,19 @@
                          context.Response.StatusCode = 401;
                          context.Response.WriteAsync(new { message = "鎺堟潈鏈�氳繃", status = false, code = 401 }.Serialize());
                          return Task.CompletedTask;
-                     }
+                     },
+                     OnMessageReceived = context =>
+                     {
+                         if (context.HttpContext.IsSuccessSwagger() == true)
+                         {
+                              string token = context.HttpContext.GetSuccessSwaggerJwt();
+                             if (token.IsNotEmptyOrNull())
+                             {
+                                 context.Token = token;
+                             }
+                         }
+                         return Task.CompletedTask;
+                     },
                  };
              });
 

--
Gitblit v1.9.3