【7.6.0】【sys】【permission】从新整理登录逻辑,封装参数校验

pull/57/head
fengshuonan 2023-06-20 23:11:05 +08:00
parent d23dab64e6
commit bb2af77c1c
1 changed files with 20 additions and 9 deletions

View File

@ -90,16 +90,9 @@ public class LoginService {
* @since 2020/10/21 16:59 * @since 2020/10/21 16:59
*/ */
public LoginResponse loginAction(LoginRequest loginRequest, Boolean validatePassword, String caToken) { public LoginResponse loginAction(LoginRequest loginRequest, Boolean validatePassword, String caToken) {
// 1.参数为空校验 // 1.参数为空校验
if (validatePassword) { this.validateEmptyParams(loginRequest, 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);
}
}
// 1.2 判断账号是否密码重试次数过多被冻结 // 1.2 判断账号是否密码重试次数过多被冻结
Integer loginErrorCount = loginErrorCountCacheApi.get(loginRequest.getAccount()); Integer loginErrorCount = loginErrorCountCacheApi.get(loginRequest.getAccount());
@ -211,6 +204,24 @@ public class LoginService {
return new LoginResponse(loginUser.getUserId(), jwtToken); 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 * loginCode
* *