mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】【permission】从新整理登录逻辑,封装参数校验
parent
d23dab64e6
commit
bb2af77c1c
|
@ -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
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue