验证码验证默认通过

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
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) {

View File

@ -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);
}
/**