Commit 4ff48c9c authored by 董建华's avatar 董建华

第一次错误只删除验证码缓存

parent 2a42a271
......@@ -619,10 +619,8 @@ public class UserController implements IBaseController {
if (smsService.needResendCode(phoneNo, VERIFICATION_CODE_FINITE_COUNT_NEW)) {
throw new VerificationCodeErrorException("验证码失效,请重新获取");
}
/**
* 删除
*/
smsService.deleteCodeFromCache(phoneNo);
smsService.deleteOnlyCodeFromCache(phoneNo);
log.info("验证码校验失败,phoneNo:{} , verificationCode:{}", phoneNo, verificationCode);
throw new VerificationCodeErrorException("短信验证码错误");
......
......@@ -47,4 +47,10 @@ public interface ISmsService {
*/
void deleteCodeFromCache(String phoneNo);
/**
* 只删除code缓存不删除尝试缓存
* @param phoneNo
*/
void deleteOnlyCodeFromCache(String phoneNo);
}
......@@ -133,10 +133,15 @@ public class SmsServiceImpl implements ISmsService {
@Override
public void deleteCodeFromCache(String phoneNo) {
String verificationCountKey = Constants.REDIS_VERIFICATION_COUNT + phoneNo;
String key = Constants.REDIS_PREFIX_VERIFICATION_CODE + phoneNo;
stringRedisTemplate.delete(key);
stringRedisTemplate.opsForHash().delete(verificationCountKey, Constants.REDIS_VERIFICATION_COUNT);
deleteOnlyCodeFromCache(phoneNo);
}
@Override
public void deleteOnlyCodeFromCache(String phoneNo) {
String key = Constants.REDIS_PREFIX_VERIFICATION_CODE + phoneNo;
stringRedisTemplate.delete(key);
}
}
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