From bb2af77c1c2f4d2de438f63c4a61ef9a6cae9cb3 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Tue, 20 Jun 2023 23:11:05 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=907.6.0=E3=80=91=E3=80=90sys=E3=80=91?= =?UTF-8?q?=E3=80=90permission=E3=80=91=E4=BB=8E=E6=96=B0=E6=95=B4?= =?UTF-8?q?=E7=90=86=E7=99=BB=E5=BD=95=E9=80=BB=E8=BE=91=EF=BC=8C=E5=B0=81?= =?UTF-8?q?=E8=A3=85=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roses/kernel/auth/auth/LoginService.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/LoginService.java b/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/LoginService.java index ed83add5d..6f12df6c5 100644 --- a/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/LoginService.java +++ b/kernel-d-auth/auth-sdk/src/main/java/cn/stylefeng/roses/kernel/auth/auth/LoginService.java @@ -90,16 +90,9 @@ public class LoginService { * @since 2020/10/21 16:59 */ public LoginResponse loginAction(LoginRequest loginRequest, Boolean validatePassword, String caToken) { + // 1.参数为空校验 - if (validatePassword) { - if (loginRequest == null || StrUtil.hasBlank(loginRequest.getAccount(), loginRequest.getPassword())) { - throw new AuthException(AuthExceptionEnum.PARAM_EMPTY); - } - } else { - if (loginRequest == null || StrUtil.hasBlank(loginRequest.getAccount())) { - throw new AuthException(AuthExceptionEnum.ACCOUNT_IS_BLANK); - } - } + this.validateEmptyParams(loginRequest, validatePassword); // 1.2 判断账号是否密码重试次数过多被冻结 Integer loginErrorCount = loginErrorCountCacheApi.get(loginRequest.getAccount()); @@ -211,6 +204,24 @@ public class LoginService { return new LoginResponse(loginUser.getUserId(), jwtToken); } + /** + * 登录接口,校验登录参数是否为空 + * + * @author fengshuonan + * @since 2023/6/20 23:10 + */ + private static void validateEmptyParams(LoginRequest loginRequest, Boolean validatePassword) { + if (validatePassword) { + if (loginRequest == null || StrUtil.hasBlank(loginRequest.getAccount(), loginRequest.getPassword())) { + throw new AuthException(AuthExceptionEnum.PARAM_EMPTY); + } + } else { + if (loginRequest == null || StrUtil.hasBlank(loginRequest.getAccount())) { + throw new AuthException(AuthExceptionEnum.ACCOUNT_IS_BLANK); + } + } + } + /** * 调用远程接口获取loginCode *