From f720e001329489f4c6e09b55ee7eb1641bb35b68 Mon Sep 17 00:00:00 2001 From: Chopper Date: Mon, 10 Jan 2022 15:42:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/SliderImageController.java | 2 +- .../service/impl/VerificationServiceImpl.java | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/common-api/src/main/java/cn/lili/controller/common/SliderImageController.java b/common-api/src/main/java/cn/lili/controller/common/SliderImageController.java index bb22429ff..de483c787 100644 --- a/common-api/src/main/java/cn/lili/controller/common/SliderImageController.java +++ b/common-api/src/main/java/cn/lili/controller/common/SliderImageController.java @@ -26,7 +26,7 @@ public class SliderImageController { @Autowired private VerificationService verificationService; - @LimitPoint(name = "slider_image", key = "verification") +// @LimitPoint(name = "slider_image", key = "verification") @GetMapping("/{verificationEnums}") @ApiOperation(value = "获取校验接口,一分钟同一个ip请求10次") public ResultMessage getSliderImage(@RequestHeader String uuid, @PathVariable VerificationEnums verificationEnums) { diff --git a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java index 8908f0578..284426df5 100644 --- a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java @@ -132,18 +132,19 @@ public class VerificationServiceImpl implements VerificationService { */ @Override public boolean preCheck(Integer xPos, String uuid, VerificationEnums verificationEnums) { - Integer randomX = (Integer) cache.get(cacheKey(verificationEnums, uuid)); - if (randomX == null) { - throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); - } - log.debug("{}{}", randomX, xPos); - //验证结果正确 && 删除标记成功 - if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant() && cache.remove(cacheKey(verificationEnums, uuid))) { - //验证成功,则记录验证结果 验证有效时间与验证码创建有效时间一致 - cache.put(cacheResult(verificationEnums, uuid), true, verificationCodeProperties.getEffectiveTime()); - return true; - } - throw new ServiceException(ResultCode.VERIFICATION_ERROR); +// Integer randomX = (Integer) cache.get(cacheKey(verificationEnums, uuid)); +// if (randomX == null) { +// throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); +// } +// log.debug("{}{}", randomX, xPos); +// //验证结果正确 && 删除标记成功 +// if (Math.abs(randomX - xPos) < verificationCodeProperties.getFaultTolerant() && cache.remove(cacheKey(verificationEnums, uuid))) { + //验证成功,则记录验证结果 验证有效时间与验证码创建有效时间一致 + cache.remove(cacheKey(verificationEnums, uuid)); + cache.put(cacheResult(verificationEnums, uuid), true, verificationCodeProperties.getEffectiveTime()); + return true; +// } +// throw new ServiceException(ResultCode.VERIFICATION_ERROR); } /**