Commit 71ac09e0 authored by 技术部-任文超's avatar 技术部-任文超

添加log,调试获取短信验证码的图片校验码超时后,使用原captchaId总能校验通过问题

parent dddd65f5
...@@ -101,7 +101,9 @@ public class RedisCaptchaStore implements CaptchaStore { ...@@ -101,7 +101,9 @@ public class RedisCaptchaStore implements CaptchaStore {
private Captcha getFromRedisThenDel(String captchaId) { private Captcha getFromRedisThenDel(String captchaId) {
String captcharKey = buildCaptcharKey(captchaId); String captcharKey = buildCaptcharKey(captchaId);
Long expire = stringRedisTemplate.getExpire(captcharKey, TimeUnit.SECONDS);
Object value = stringRedisTemplate.opsForValue().get(captcharKey); Object value = stringRedisTemplate.opsForValue().get(captcharKey);
LOGGER.info("captchaId={},captchaCode={},expire={}秒", captcharKey, value, expire);
stringRedisTemplate.delete(captcharKey); stringRedisTemplate.delete(captcharKey);
return value != null ? new SimpleCaptcha(captchaId, String.valueOf(value)) : null; return value != null ? new SimpleCaptcha(captchaId, String.valueOf(value)) : null;
} }
......
...@@ -34,6 +34,9 @@ public class SimpleCaptcha extends ImageCaptcha { ...@@ -34,6 +34,9 @@ public class SimpleCaptcha extends ImageCaptcha {
} }
private Boolean validateResponse(String response) { private Boolean validateResponse(String response) {
if(StringUtils.isBlank(this.response) || StringUtils.isBlank(response)){
return false;
}
return StringUtils.equals(this.response, response); return StringUtils.equals(this.response, response);
} }
......
package login;
import java.nio.charset.Charset;
import java.util.Base64;
public class TestStringCode {
public static void main(String[] args) {
System.out.println(base64("13511112222", "000000"));
System.out.println(base64("18022223333", "000000"));
}
final static String AUTHORIZATION = "authorization";
final static String PREFIX = "Basic ";
/*
* 4.153
* 13576450525 123456 318e235d3e52648b236faa3f748000d5
* 13724823305 123456 318e235d3e52648b236faa3f748000d5
*
* 4.155
* 13511112222 000000 c8937b92506c0e2918de053dea69edd3
* 18022223333 000000 c8937b92506c0e2918de053dea69edd3
*/
final static String base64(String account, String password) {
String authorization = PREFIX + new String(Base64.getEncoder().encodeToString((account+":"+password).getBytes(Charset.forName("UTF-8"))));
return authorization;
}
}
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