From cef26e770ed460ec2a5ef83ae7049be2beaf6b1e Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 20 Nov 2019 12:08:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=80=80=E5=87=BA=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=94=A8=E6=88=B7=E7=BC=93=E5=AD=98=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/handle/LogoutSuccessHandlerImpl.java | 2 ++ .../framework/security/service/TokenService.java | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java b/ruoyi/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java index e8883a576..c2cc60baa 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java @@ -43,6 +43,8 @@ public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler if (StringUtils.isNotNull(loginUser)) { String userName = loginUser.getUsername(); + // 删除用户缓存记录 + tokenService.delLoginUser(loginUser.getToken()); // 记录用户退出日志 AsyncManager.me().execute(AsyncFactory.recordLogininfor(userName, Constants.LOGOUT, "退出成功")); } diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java b/ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java index 8e8de0584..dc33e8930 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java +++ b/ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java @@ -82,6 +82,18 @@ public class TokenService } } + /** + * 删除用户身份信息 + */ + public void delLoginUser(String token) + { + if (StringUtils.isNotEmpty(token)) + { + String userKey = getTokenKey(token); + redisCache.deleteObject(userKey); + } + } + /** * 创建令牌 *