use of com.albedo.java.modules.sys.domain.UserOnlineDo in project albedo by somowhere.
the class SysUserOnlineListener method saveSysUserOnlineRefreshLastRequestEvent.
@Async
@Order
@EventListener(SysUserOnlineRefreshLastRequestEvent.class)
public void saveSysUserOnlineRefreshLastRequestEvent(SysUserOnlineRefreshLastRequestEvent event) {
SessionInformation sessionInformation = (SessionInformation) event.getSource();
UserOnlineDo userOnlineDo = userOnlineService.getById(sessionInformation.getSessionId());
if (userOnlineDo != null) {
userOnlineDo.setLastAccessTime(LocalDateTimeUtil.of(sessionInformation.getLastRequest()));
userOnlineService.updateById(userOnlineDo);
} else {
log.debug("sessionInformation sessionId " + sessionInformation.getSessionId() + ", onlineUser is null");
}
}
use of com.albedo.java.modules.sys.domain.UserOnlineDo in project albedo by somowhere.
the class AjaxAuthenticationSuccessHandler method onAuthenticationSuccess.
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
response.setStatus(HttpServletResponse.SC_OK);
String useruame = request.getParameter("username");
LoginUtil.isValidateCodeLogin(useruame, false, true);
UserOnlineDo userOnlineDo = LoginUtil.getUserOnline(authentication);
SpringContextHolder.publishEvent(new SysUserOnlineEvent(userOnlineDo));
LogLoginDo logLoginDo = SysLogUtils.getSysLogLogin();
logLoginDo.setParams(HttpUtil.toParams(request.getParameterMap()));
logLoginDo.setUsername(useruame);
logLoginDo.setTitle("用户登录");
AsyncUtil.recordLogLogin(logLoginDo);
WebUtil.renderJson(response, Result.buildOk("登录成功"));
}
use of com.albedo.java.modules.sys.domain.UserOnlineDo in project albedo by somowhere.
the class UserOnlineResource method remove.
@PreAuthorize("@pms.hasPermission('sys_userOnline_del')")
@LogOperate(value = "在线用户删除")
@DeleteMapping
public Result remove(@RequestBody Set<String> ids, HttpServletRequest request) {
for (String id : ids) {
UserOnlineDo online = userOnlineService.getById(id);
if (online == null) {
return Result.buildFail("用户已下线");
}
try {
SessionInformation sessionInformation = sessionRegistry.getSessionInformation(online.getSessionId());
if (sessionInformation != null) {
if (sessionInformation.getSessionId().equals(request.getSession(false).getId())) {
return Result.buildFail("当前登陆用户无法删除");
}
sessionInformation.expireNow();
redisTemplate.boundHashOps(RedisSessionRegistry.SESSIONIDS).put(online.getSessionId(), sessionInformation);
}
} catch (Exception e) {
}
sessionRegistry.removeSessionInformation(online.getSessionId());
userOnlineService.removeById(online);
}
return Result.buildOk("操作成功");
}
Aggregations