use of com.albedo.java.modules.sys.domain.LogLoginDo in project albedo by somowhere.
the class AjaxAuthenticationFailureHandler method onAuthenticationFailure.
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) {
String username = request.getParameter("username");
LoginUtil.isValidateCodeLogin(username, true, false);
String message = exception instanceof BadCredentialsException && "Bad credentials".equals(exception.getMessage()) ? "密码填写错误!" : exception.getMessage();
LogLoginDo logLoginDo = SysLogUtils.getSysLogLogin();
logLoginDo.setParams(HttpUtil.toParams(request.getParameterMap()));
logLoginDo.setUsername(username);
try {
UserDetail userDetails = (UserDetail) userDetailsService.loadUserByUsername(username);
if (userDetails != null) {
logLoginDo.setCreatedBy(userDetails.getId());
}
} catch (Exception e) {
log.debug("can not find createId by username[{}]", username);
}
logLoginDo.setTitle("用户登录失败");
logLoginDo.setDescription(message);
AsyncUtil.recordLogLogin(logLoginDo);
response.setStatus(HttpServletResponse.SC_OK);
WebUtil.renderJson(response, Result.buildFail(message));
}
use of com.albedo.java.modules.sys.domain.LogLoginDo 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.LogLoginDo in project albedo by somowhere.
the class SysLogLoginListener method saveSysLog.
@Async
@Order
@EventListener(SysLogLoginEvent.class)
public void saveSysLog(SysLogLoginEvent event) {
LogLoginDo logLoginDo = (LogLoginDo) event.getSource();
logLoginService.save(logLoginDo);
}
use of com.albedo.java.modules.sys.domain.LogLoginDo in project albedo by somowhere.
the class LogLoginResource method download.
@LogOperate(value = "登录日志导出")
@Operation(summary = "登录日志导出")
@GetMapping(value = "/download")
@PreAuthorize("@pms.hasPermission('sys_logOperate_export')")
public void download(LogLoginQueryCriteria logOperateQueryCriteria, HttpServletResponse response) {
QueryWrapper wrapper = QueryWrapperUtil.getWrapper(logOperateQueryCriteria);
ExcelUtil<LogLoginDo> util = new ExcelUtil(LogLoginDo.class);
util.exportExcel(service.list(wrapper), "登录日志", response);
}
Aggregations