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

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

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