From 1118be4fe9e88bc374124a4448e2d1318546aab6 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Thu, 19 Oct 2023 14:45:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AD=98=E5=9C=A8session=5Ftoekn?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B9=B6=E5=BB=B6=E9=95=BF=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib_features/account/account.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib_features/account/account.go b/src/lib_features/account/account.go index 2bdfd8fc..9e4e5eaf 100644 --- a/src/lib_features/account/account.go +++ b/src/lib_features/account/account.go @@ -14,7 +14,13 @@ import ( func SessionToken(username, sourceAddr string) bool { token, _ := redis.Get("", "session_token") if token != "" { - return true + se, err := dborm.XormUpdateSessionShakeTime(token) + if se.AccountId != username || err != nil { + // 过期时间单位秒 配置1800是半小时 + expireTime := time.Duration(int64(libConfig.GetExpiresFromConfig())) * time.Second + redis.SetByExpire("", "session_token", token, expireTime) + return true + } } token = oauth.GenRandToken("omc") // Generate new token to session ID