验证码验证默认通过
This commit is contained in:
parent
f723c11a84
commit
f720e00132
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user