✨ Introducing new features. close #3794 【新需求】登录错误次数限制,连续登录失败锁定账号

This commit is contained in:
卢本伟 committed 2022-04-11 17:36:02 +08:00
1 parent f669d1b968
commit 2c02514fcf
2 files changed
+6 -3

No files matched your search

@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.common.security.listener;
import cn.hutool.core.collection.CollUtil;
import com.pig4cloud.pigx.common.security.handler.AuthenticationFailureHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
@@ -60,8 +61,10 @@ public class AuthenticationFailureEventListener implements ApplicationListener<A
Authentication authentication = (Authentication) event.getSource();
// 调用自定义业务链实现
failureHandlerList.forEach(
failureHandler -> failureHandler.handle(authenticationException, authentication, request, response));
if (CollUtil.isNotEmpty(failureHandlerList)) {
failureHandlerList.forEach(failureHandler -> failureHandler.handle(authenticationException, authentication,
request, response));
}
}
}
@@ -47,7 +47,7 @@ public class AuthenticationSuccessEventListener implements ApplicationListener<A
@Override
public void onApplicationEvent(AuthenticationSuccessEvent event) {
Authentication authentication = (Authentication) event.getSource();
if (isUserAuthentication(authentication)) {
if (CollUtil.isNotEmpty(successHandlerList) && isUserAuthentication(authentication)) {
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
.getRequestAttributes();
HttpServletRequest request = requestAttributes.getRequest();