验证码验证默认通过

This commit is contained in:
Chopper 2022-01-10 15:42:32 +08:00
parent f723c11a84
commit f720e00132
2 changed files with 14 additions and 13 deletions

View File

@ -26,7 +26,7 @@ public class SliderImageController {
@Autowired @Autowired
private VerificationService verificationService; private VerificationService verificationService;
@LimitPoint(name = "slider_image", key = "verification") // @LimitPoint(name = "slider_image", key = "verification")
@GetMapping("/{verificationEnums}") @GetMapping("/{verificationEnums}")
@ApiOperation(value = "获取校验接口,一分钟同一个ip请求10次") @ApiOperation(value = "获取校验接口,一分钟同一个ip请求10次")
public ResultMessage getSliderImage(@RequestHeader String uuid, @PathVariable VerificationEnums verificationEnums) { public ResultMessage getSliderImage(@RequestHeader String uuid, @PathVariable VerificationEnums verificationEnums) {

View File

@ -132,18 +132,19 @@ public class VerificationServiceImpl implements VerificationService {
*/ */
@Override @Override
public boolean preCheck(Integer xPos, String uuid, VerificationEnums verificationEnums) { public boolean preCheck(Integer xPos, String uuid, VerificationEnums verificationEnums) {
Integer randomX = (Integer) cache.get(cacheKey(verificationEnums, uuid)); // Integer randomX = (Integer) cache.get(cacheKey(verificationEnums, uuid));
if (randomX == null) { // if (randomX == null) {
throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); // throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID);
} // }
log.debug("{}{}", randomX, xPos); // log.debug("{}{}", randomX, xPos);
//验证结果正确 && 删除标记成功 // //验证结果正确 && 删除标记成功
if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant() && cache.remove(cacheKey(verificationEnums, uuid))) { // if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant() && cache.remove(cacheKey(verificationEnums, uuid))) {
//验证成功则记录验证结果 验证有效时间与验证码创建有效时间一致 //验证成功则记录验证结果 验证有效时间与验证码创建有效时间一致
cache.put(cacheResult(verificationEnums, uuid), true, verificationCodeProperties.getEffectiveTime()); cache.remove(cacheKey(verificationEnums, uuid));
return true; cache.put(cacheResult(verificationEnums, uuid), true, verificationCodeProperties.getEffectiveTime());
} return true;
throw new ServiceException(ResultCode.VERIFICATION_ERROR); // }
// throw new ServiceException(ResultCode.VERIFICATION_ERROR);
} }
/** /**