From 8f3aee72e9eb052d58ee573283e6b859b2009fb5 Mon Sep 17 00:00:00 2001 From: dushixiang <798148596@qq.com> Date: Tue, 23 Feb 2021 22:57:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E9=80=80?= =?UTF-8?q?=E5=87=BA=E7=99=BB=E5=BD=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 2 +- pkg/api/account.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 3d8dfbb..63546b5 100644 --- a/main.go +++ b/main.go @@ -168,7 +168,7 @@ func Run() error { global.Cache = cache.New(5*time.Minute, 10*time.Minute) global.Cache.OnEvicted(func(key string, value interface{}) { if strings.HasPrefix(key, api.Token) { - token := strings.Split(key, ":")[0] + token := strings.Split(key, ":")[1] logrus.Debugf("用户Token「%v」过期", token) model.Logout(token) } diff --git a/pkg/api/account.go b/pkg/api/account.go index 4b3ed06..c673de1 100644 --- a/pkg/api/account.go +++ b/pkg/api/account.go @@ -165,7 +165,8 @@ func loginWithTotpEndpoint(c echo.Context) error { func LogoutEndpoint(c echo.Context) error { token := GetToken(c) - global.Cache.Delete(token) + cacheKey := strings.Join([]string{Token, token}, ":") + global.Cache.Delete(cacheKey) model.Logout(token) return Success(c, nil) }