From bb219fb6dc35a34ee72d8a14c2c469070049ccc9 Mon Sep 17 00:00:00 2001 From: zjf <1799650030@qq.com> Date: Wed, 24 Jun 2026 09:30:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E7=A1=AE=E8=AE=A4=E4=B8=8D?= =?UTF-8?q?=E8=AE=B0=E5=A4=B1=E8=B4=A5=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...jcloudAuthenticationFailureEventHandler.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pjcloud-auth/src/main/java/com/bsd/pjcloud/auth/support/handler/PjcloudAuthenticationFailureEventHandler.java b/pjcloud-auth/src/main/java/com/bsd/pjcloud/auth/support/handler/PjcloudAuthenticationFailureEventHandler.java index 4ef8f487..fd4eacbe 100644 --- a/pjcloud-auth/src/main/java/com/bsd/pjcloud/auth/support/handler/PjcloudAuthenticationFailureEventHandler.java +++ b/pjcloud-auth/src/main/java/com/bsd/pjcloud/auth/support/handler/PjcloudAuthenticationFailureEventHandler.java @@ -29,6 +29,7 @@ import com.bsd.pjcloud.common.data.resolver.ParamResolver; import com.bsd.pjcloud.common.log.event.SysLogEvent; import com.bsd.pjcloud.common.log.util.LogTypeEnum; import com.bsd.pjcloud.common.log.util.SysLogUtils; +import com.bsd.pjcloud.common.security.util.OAuth2ErrorCodesExpand; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; @@ -89,10 +90,11 @@ public class PjcloudAuthenticationFailureEventHandler implements AuthenticationF if (OAuth2ParameterNames.PASSWORD.equals(grantType)) { String username = request.getParameter(OAuth2ParameterNames.USERNAME); - // 密码错误记录错误次数 (TOC用户不记录) + // 密码错误记录错误次数 (TOC用户不记录;微信绑定/确认门禁不算失败) String header = WebUtils.getRequest().getHeader(SecurityConstants.HEADER_TOC); - if (exception instanceof OAuth2AuthenticationException - && !SecurityConstants.HEADER_TOC_YES.equals(header)) { + if (exception instanceof OAuth2AuthenticationException oauth2Ex + && !SecurityConstants.HEADER_TOC_YES.equals(header) + && !isWechatGateError(oauth2Ex)) { recordLoginFailureTimes(username); } @@ -131,6 +133,15 @@ public class PjcloudAuthenticationFailureEventHandler implements AuthenticationF publisher.publishEvent(new SysLogEvent(logVo)); } + /** + * PC 微信绑定/扫码确认:密码已校验通过,不应计入登录失败锁定 + */ + private boolean isWechatGateError(OAuth2AuthenticationException exception) { + String errorCode = exception.getError().getErrorCode(); + return OAuth2ErrorCodesExpand.WECHAT_BIND_REQUIRED.equals(errorCode) + || OAuth2ErrorCodesExpand.WECHAT_CONFIRM_REQUIRED.equals(errorCode); + } + /** * 记录登录失败此处,如果操作阈值 调用接口锁定用户 *