新增用户安全相关的
This commit is contained in:
@@ -233,4 +233,35 @@ public class SysLoginService
|
||||
userService.resetUserPwd(sysUser.getUserId(), SecurityUtils.encryptPassword(password));
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*
|
||||
* @param loginUser 登录用户信息
|
||||
*/
|
||||
public void logout(LoginUser loginUser)
|
||||
{
|
||||
if (loginUser != null)
|
||||
{
|
||||
String token = loginUser.getToken();
|
||||
|
||||
// TODO: 安全功能集成 - 更新会话状态为已登出
|
||||
// 在用户退出登录时,更新hotake_security_login_sessions表中的会话状态
|
||||
// 记录登出时间,并将is_active设置为0
|
||||
try {
|
||||
Object securityService = com.vetti.common.utils.spring.SpringUtils.getBean("hotakeSecurityServiceImpl");
|
||||
if (securityService != null) {
|
||||
// 使用反射调用更新会话状态的方法
|
||||
java.lang.reflect.Method method = securityService.getClass().getMethod(
|
||||
"updateSessionLogout", String.class);
|
||||
method.invoke(securityService, token);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 更新会话状态失败不影响退出流程
|
||||
}
|
||||
|
||||
// 删除用户缓存记录
|
||||
tokenService.delLoginUser(token);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user