From b9009bbd482ef7e594e05fe382d6127cc89f076f Mon Sep 17 00:00:00 2001 From: wangyazhou <564631192@qq.com> Date: Tue, 28 Oct 2025 15:14:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(jwt):=E4=BF=AE=E6=AD=A3=E4=BB=A4=E7=89=8C?= =?UTF-8?q?=E8=BF=87=E6=9C=9F=E6=97=B6=E9=97=B4=E8=AE=A1=E7=AE=97=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整了SetToken函数中的过期时间单位,从秒转换为分钟 - 确保新令牌的过期时间与配置保持一致- 修复了因时间单位不匹配导致的令牌提前失效问题 --- server/middleware/jwt.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/middleware/jwt.go b/server/middleware/jwt.go index 7715ed9c..f4c02962 100644 --- a/server/middleware/jwt.go +++ b/server/middleware/jwt.go @@ -2,11 +2,12 @@ package middleware import ( "errors" + "strconv" + "time" + "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/utils" "github.com/golang-jwt/jwt/v5" - "strconv" - "time" "github.com/flipped-aurora/gin-vue-admin/server/model/common/response" "github.com/gin-gonic/gin" @@ -59,7 +60,7 @@ func JWTAuth() gin.HandlerFunc { newClaims, _ := j.ParseToken(newToken) c.Header("new-token", newToken) c.Header("new-expires-at", strconv.FormatInt(newClaims.ExpiresAt.Unix(), 10)) - utils.SetToken(c, newToken, int(dr.Seconds())) + utils.SetToken(c, newToken, int(dr.Seconds()/60)) if global.GVA_CONFIG.System.UseMultipoint { // 记录新的活跃jwt _ = utils.SetRedisJWT(newToken, newClaims.Username)