修复无法退出登录的问题

This commit is contained in:
dushixiang
2021-02-23 22:57:40 +08:00
parent 87586da40a
commit 8f3aee72e9
2 changed files with 3 additions and 2 deletions

View File

@ -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)
}

View File

@ -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)
}