修复无法退出登录的问题
This commit is contained in:
2
main.go
2
main.go
@ -168,7 +168,7 @@ func Run() error {
|
|||||||
global.Cache = cache.New(5*time.Minute, 10*time.Minute)
|
global.Cache = cache.New(5*time.Minute, 10*time.Minute)
|
||||||
global.Cache.OnEvicted(func(key string, value interface{}) {
|
global.Cache.OnEvicted(func(key string, value interface{}) {
|
||||||
if strings.HasPrefix(key, api.Token) {
|
if strings.HasPrefix(key, api.Token) {
|
||||||
token := strings.Split(key, ":")[0]
|
token := strings.Split(key, ":")[1]
|
||||||
logrus.Debugf("用户Token「%v」过期", token)
|
logrus.Debugf("用户Token「%v」过期", token)
|
||||||
model.Logout(token)
|
model.Logout(token)
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,8 @@ func loginWithTotpEndpoint(c echo.Context) error {
|
|||||||
|
|
||||||
func LogoutEndpoint(c echo.Context) error {
|
func LogoutEndpoint(c echo.Context) error {
|
||||||
token := GetToken(c)
|
token := GetToken(c)
|
||||||
global.Cache.Delete(token)
|
cacheKey := strings.Join([]string{Token, token}, ":")
|
||||||
|
global.Cache.Delete(cacheKey)
|
||||||
model.Logout(token)
|
model.Logout(token)
|
||||||
return Success(c, nil)
|
return Success(c, nil)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user