Commit 992fa04c authored by 唐峰's avatar 唐峰

增加静默异常

parent 9e9c9b11
...@@ -27,7 +27,7 @@ public class CustomSentryExceptionResolver implements HandlerExceptionResolver, ...@@ -27,7 +27,7 @@ public class CustomSentryExceptionResolver implements HandlerExceptionResolver,
Object handler, Object handler,
Exception ex) { Exception ex) {
// TODO: 2020/2/4 临时测试,后期修改成通用。 // TODO: 2020/2/4 临时测试,后期修改成通用。
if (ex instanceof VerificationCodeErrorException || ex instanceof DataException || ex instanceof UserRegisterLoginException if (ex instanceof SilentBizException || ex instanceof VerificationCodeErrorException || ex instanceof DataException || ex instanceof UserRegisterLoginException
|| ex instanceof AppletException || ex instanceof AccessForbiddenException || ex instanceof PasswordErrorLimitException || ex instanceof BadCredentialsException) { || ex instanceof AppletException || ex instanceof AccessForbiddenException || ex instanceof PasswordErrorLimitException || ex instanceof BadCredentialsException) {
return null; return null;
} }
......
...@@ -206,4 +206,8 @@ public class ExceptionHandlingController implements IBaseController { ...@@ -206,4 +206,8 @@ public class ExceptionHandlingController implements IBaseController {
public JsonResult<?> handleBizException(BizException e) { public JsonResult<?> handleBizException(BizException e) {
return JsonResult.buildErrorResultWhithCode(e.getMsg(),e.getBusinessCode()); return JsonResult.buildErrorResultWhithCode(e.getMsg(),e.getBusinessCode());
} }
@ExceptionHandler(SilentBizException.class)
public JsonResult<?> handleSilentBizException(BizException e) {
return JsonResult.buildErrorResultWhithCode(e.getMsg(),e.getBusinessCode());
}
} }
package cn.quantgroup.xyqb.exception;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
public class SilentBizException extends RuntimeException {
private String msg;
private String businessCode;
public SilentBizException(BizExceptionEnum bizExceptionEnum) {
this.msg = bizExceptionEnum.getMsg();
this.businessCode = bizExceptionEnum.getBusinessCode();
}
public SilentBizException(BizExceptionEnum bizExceptionEnum, String attach) {
this.msg = bizExceptionEnum.getMsg()+attach;
this.businessCode = bizExceptionEnum.getBusinessCode();
}
}
...@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.controller.req.v2.LoginReq; ...@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.controller.req.v2.LoginReq;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.exception.BizException; import cn.quantgroup.xyqb.exception.BizException;
import cn.quantgroup.xyqb.exception.BizExceptionEnum; import cn.quantgroup.xyqb.exception.BizExceptionEnum;
import cn.quantgroup.xyqb.exception.SilentBizException;
import cn.quantgroup.xyqb.model.AuthBean; import cn.quantgroup.xyqb.model.AuthBean;
import cn.quantgroup.xyqb.model.LoginBean; import cn.quantgroup.xyqb.model.LoginBean;
import cn.quantgroup.xyqb.model.LoginProperties; import cn.quantgroup.xyqb.model.LoginProperties;
...@@ -68,7 +69,7 @@ public class PhonePasswordLoginStrategy implements LoginStrategy { ...@@ -68,7 +69,7 @@ public class PhonePasswordLoginStrategy implements LoginStrategy {
lockIpv4Service.countErrorByIpv4(sessionStruct.getIp()); lockIpv4Service.countErrorByIpv4(sessionStruct.getIp());
// 向该phoneNo添加错误计数器 // 向该phoneNo添加错误计数器
lockIpv4Service.countErrorByPhoneNo(phonePasswordLoginParam.getPhone()); lockIpv4Service.countErrorByPhoneNo(phonePasswordLoginParam.getPhone());
throw new BizException(BizExceptionEnum.ERROR_PASSWORD); throw new SilentBizException(BizExceptionEnum.ERROR_PASSWORD);
} }
} else { } else {
//验证密码 //验证密码
...@@ -77,7 +78,7 @@ public class PhonePasswordLoginStrategy implements LoginStrategy { ...@@ -77,7 +78,7 @@ public class PhonePasswordLoginStrategy implements LoginStrategy {
lockIpv4Service.countErrorByIpv4(sessionStruct.getIp()); lockIpv4Service.countErrorByIpv4(sessionStruct.getIp());
// 向该phoneNo添加错误计数器 // 向该phoneNo添加错误计数器
lockIpv4Service.countErrorByPhoneNo(phonePasswordLoginParam.getPhone()); lockIpv4Service.countErrorByPhoneNo(phonePasswordLoginParam.getPhone());
throw new BizException(BizExceptionEnum.ERROR_PASSWORD); throw new SilentBizException(BizExceptionEnum.ERROR_PASSWORD);
} }
// 校验老密码正确更新新加密方式 // 校验老密码正确更新新加密方式
user.setCipherPassword(BctyptPasswordUtil.BCryptWithSalt(phonePasswordLoginParam.getPassword())); user.setCipherPassword(BctyptPasswordUtil.BCryptWithSalt(phonePasswordLoginParam.getPassword()));
......
...@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.controller.req.v2.LoginReq; ...@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.controller.req.v2.LoginReq;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.exception.BizException; import cn.quantgroup.xyqb.exception.BizException;
import cn.quantgroup.xyqb.exception.BizExceptionEnum; import cn.quantgroup.xyqb.exception.BizExceptionEnum;
import cn.quantgroup.xyqb.exception.SilentBizException;
import cn.quantgroup.xyqb.model.*; import cn.quantgroup.xyqb.model.*;
import cn.quantgroup.xyqb.model.session.SessionStruct; import cn.quantgroup.xyqb.model.session.SessionStruct;
import cn.quantgroup.xyqb.model.v2.login.BaseLoginParam; import cn.quantgroup.xyqb.model.v2.login.BaseLoginParam;
...@@ -73,7 +74,7 @@ public class SMSDirectJiLoginStrategy implements LoginStrategy { ...@@ -73,7 +74,7 @@ public class SMSDirectJiLoginStrategy implements LoginStrategy {
} }
if (jiGuangResponseParam == null || 8000 != jiGuangResponseParam.getCode()) { if (jiGuangResponseParam == null || 8000 != jiGuangResponseParam.getCode()) {
throw new BizException(BizExceptionEnum.ERROR_DIRECT_LOGIN); throw new SilentBizException(BizExceptionEnum.ERROR_DIRECT_LOGIN);
} else { } else {
smsLoginParam.setPhone(jiGuangResponseParam.getPhone()); smsLoginParam.setPhone(jiGuangResponseParam.getPhone());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment