mirror of https://gitee.com/stylefeng/roses
【8.1.9】【sys】更新登录失败的日志,增加客户端ip的参数
parent
c63b965e03
commit
49e1e57113
|
@ -330,7 +330,7 @@ public class LoginService {
|
||||||
loginErrorCountCacheApi.put(loginRequest.getAccount(), loginErrorCount + 1);
|
loginErrorCountCacheApi.put(loginRequest.getAccount(), loginErrorCount + 1);
|
||||||
|
|
||||||
// 记录登录失败日志
|
// 记录登录失败日志
|
||||||
AsyncLogManager.getInstance().recordLoginLogFail(loginRequest.getAccount());
|
AsyncLogManager.getInstance().recordLoginLogFail(loginRequest.getAccount(), HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest()));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new AuthException(AuthExceptionEnum.USERNAME_PASSWORD_ERROR);
|
throw new AuthException(AuthExceptionEnum.USERNAME_PASSWORD_ERROR);
|
||||||
|
|
|
@ -59,7 +59,7 @@ public interface LoginLogServiceApi {
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @since 2024/7/10 17:30
|
* @since 2024/7/10 17:30
|
||||||
*/
|
*/
|
||||||
void loginFail(String account);
|
void loginFail(String account, String ip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加退出成功日志
|
* 增加退出成功日志
|
||||||
|
|
|
@ -49,13 +49,13 @@ public class AsyncLogManager {
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @since 2024/7/10 17:29
|
* @since 2024/7/10 17:29
|
||||||
*/
|
*/
|
||||||
public void recordLoginLogFail(String account) {
|
public void recordLoginLogFail(String account, String ip) {
|
||||||
this.executeLog(new TimerTask() {
|
this.executeLog(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
LoginLogServiceApi loginLogServiceApi = SpringUtil.getBean(LoginLogServiceApi.class);
|
LoginLogServiceApi loginLogServiceApi = SpringUtil.getBean(LoginLogServiceApi.class);
|
||||||
loginLogServiceApi.loginFail(account);
|
loginLogServiceApi.loginFail(account, ip);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("记录登录失败日志异常!", e);
|
log.error("记录登录失败日志异常!", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,12 +102,12 @@ public class SysLoginLogServiceImpl extends ServiceImpl<SysLoginLogMapper, SysLo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loginFail(String account) {
|
public void loginFail(String account, String ip) {
|
||||||
SysLoginLog sysLoginLog = new SysLoginLog();
|
SysLoginLog sysLoginLog = new SysLoginLog();
|
||||||
sysLoginLog.setLlgName(LoginLogConstant.LOGIN_IN_LOGINNAME);
|
sysLoginLog.setLlgName(LoginLogConstant.LOGIN_IN_LOGINNAME);
|
||||||
sysLoginLog.setLlgSucceed(LoginLogConstant.OPERATION_FAIL);
|
sysLoginLog.setLlgSucceed(LoginLogConstant.OPERATION_FAIL);
|
||||||
sysLoginLog.setLlgMessage(LoginLogConstant.LOGIN_IN_SUCCESS_FAIL);
|
sysLoginLog.setLlgMessage(LoginLogConstant.LOGIN_IN_SUCCESS_FAIL);
|
||||||
sysLoginLog.setLlgIpAddress(HttpServletUtil.getRequestClientIp(HttpServletUtil.getRequest()));
|
sysLoginLog.setLlgIpAddress(ip);
|
||||||
sysLoginLog.setAccount(account);
|
sysLoginLog.setAccount(account);
|
||||||
this.save(sysLoginLog);
|
this.save(sysLoginLog);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue