Commit a1b39974 authored by 董建华's avatar 董建华

图形验证码调整到1分钟给测试用

parent 4ff48c9c
......@@ -172,7 +172,7 @@ public interface Constants {
/**
* 图形验证码有效期
*/
Long IMAGE_CAPTCHA_REDIS_CACHE_TIME_OUT = 10L;
Long IMAGE_CAPTCHA_REDIS_CACHE_TIME_OUT = 1L;
/**
* 默认随机密码长度
*/
......
......@@ -616,7 +616,7 @@ public class UserController implements IBaseController {
private void verifyPhoneAndCodeForOnce(String phoneNo, String verificationCode) {
if (!smsService.verifyPhoneAndCode(phoneNo, verificationCode)) {
// 是否需要重新发送短信验证码
if (smsService.needResendCode(phoneNo, VERIFICATION_CODE_FINITE_COUNT_NEW)) {
if (smsService.needResendCode(phoneNo, VERIFICATION_CODE_FINITE_COUNT_NEW,false)) {
throw new VerificationCodeErrorException("验证码失效,请重新获取");
}
......
......@@ -34,12 +34,13 @@ public interface ISmsService {
boolean needResendCode(String phoneNo);
/**
* 是否需要重新发送短信验证码
*
* @param phoneNo
* @param threshold
* @param isDelTryCount 是否删除尝试登录次数
* @return
*/
boolean needResendCode(String phoneNo,Long threshold);
boolean needResendCode(String phoneNo,Long threshold,boolean isDelTryCount);
/**
* 删除验证码缓存
......
......@@ -115,17 +115,21 @@ public class SmsServiceImpl implements ISmsService {
@Override
public boolean needResendCode(String phoneNo) {
return needResendCode(phoneNo, Constants.VERIFICATION_CODE_FINITE_COUNT);
return needResendCode(phoneNo, Constants.VERIFICATION_CODE_FINITE_COUNT,true);
}
@Override
public boolean needResendCode(String phoneNo, Long threshold) {
public boolean needResendCode(String phoneNo, Long threshold,boolean isDelTryCount) {
String verificationCountKey = Constants.REDIS_VERIFICATION_COUNT + phoneNo;
Long getVerificationCount = stringRedisTemplate.opsForHash().increment(verificationCountKey, Constants.REDIS_VERIFICATION_COUNT, 1);
boolean needResend = getVerificationCount >= threshold;
if (needResend) {
deleteCodeFromCache(phoneNo);
if (isDelTryCount) {
deleteCodeFromCache(phoneNo);
} else {
deleteOnlyCodeFromCache(phoneNo);
}
}
return needResend;
}
......
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