feat: 新增登出日志方法

This commit is contained in:
lhc
2025-12-02 10:16:24 +08:00
parent acfab15b3b
commit a7d2aa06dc
2 changed files with 8 additions and 0 deletions

View File

@@ -75,6 +75,7 @@ public class CustomRealm extends AuthorizingRealm {
long time = Long.parseLong((String) redisUtil.hget("tokenSession:" + accessToken, "expireTime"));
if (time < System.currentTimeMillis()) {
redisUtil.del(accessToken);
systemRealm.setTimeoutLogoutLog(userId);
throw new IncorrectCredentialsException("token失效请重新登录");
}
} else {
@@ -83,6 +84,7 @@ public class CustomRealm extends AuthorizingRealm {
userId = String.valueOf(tokenEntity.getUserId());
//2. token失效
if (tokenEntity.getExpireTime().getTime() < System.currentTimeMillis()) {
systemRealm.setTimeoutLogoutLog(userId);
throw new IncorrectCredentialsException("token失效请重新登录");
}
}

View File

@@ -32,4 +32,10 @@ public interface SystemRealm {
*/
LinkedHashMap<String, String> setShiroUrl();
/**
* 设置登出日志
* @param userId
*/
void setTimeoutLogoutLog(String userId);
}