From c3a531c4eec6002ab81b6add81ff81b92bd30142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=A2=93=E5=BD=AD?= Date: Wed, 30 Sep 2026 08:38:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=81=E5=88=A4=E8=B4=A6=E5=8F=B7=20JWT=20?= =?UTF-8?q?=E6=9C=89=E6=95=88=E6=9C=9F=E8=B0=83=E6=95=B4=E4=B8=BA=2024=20?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YD_Event.Application/Client/OAuthController.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/YD_Event.Application/Client/OAuthController.cs b/YD_Event.Application/Client/OAuthController.cs index e8deeee..2278558 100644 --- a/YD_Event.Application/Client/OAuthController.cs +++ b/YD_Event.Application/Client/OAuthController.cs @@ -18,6 +18,9 @@ public class OAuthController : IDynamicApiController private readonly ILogger _logger; private const string SmsCodeCachePrefix = "sms:code:"; + private const long RefereeAccessTokenExpiredMinutes = 24 * 60; + private const int DefaultAccessTokenExpiresInSeconds = 2 * 60 * 60; + private const int RefereeAccessTokenExpiresInSeconds = 24 * 60 * 60; public OAuthController( ISqlSugarRepository appUserRepository, @@ -120,7 +123,9 @@ public class OAuthController : IDynamicApiController { AccessToken = accessToken, RefreshToken = refreshToken, - ExpiresIn = 7200, + ExpiresIn = appUser.MiniProgramRole == MiniProgramRole.Referee + ? RefereeAccessTokenExpiresInSeconds + : DefaultAccessTokenExpiresInSeconds, UserInfo = userInfo }; } @@ -300,13 +305,16 @@ public class OAuthController : IDynamicApiController private (string AccessToken, string RefreshToken) GenerateTokens(YD_Event.Core.Entities.AppUser appUser) { long uniqueId = _idGenerator.NewLong(); + long? accessTokenExpiredMinutes = appUser.MiniProgramRole == MiniProgramRole.Referee + ? RefereeAccessTokenExpiredMinutes + : null; string accessToken = JWTEncryption.Encrypt(new Dictionary() { [AuthClaimsConst.AuthIdKey] = appUser.Id, [AuthClaimsConst.AccountKey] = appUser.Mobile, [AuthClaimsConst.UuidKey] = uniqueId, [AuthClaimsConst.AuthPlatformTypeKey] = AuthPlatformType.WeChatApplet - }); + }, accessTokenExpiredMinutes); string refreshToken = JWTEncryption.GenerateRefreshToken(accessToken);