refactor(security): Validator.isMobile randomStr

This commit is contained in:
冷冷 2024-08-02 19:14:09 +08:00
parent 011441b9f7
commit 6affe64e92

View File

@ -1,5 +1,6 @@
package com.pig4cloud.pig.auth.endpoint;
import cn.hutool.core.lang.Validator;
import com.pig4cloud.pig.common.core.constant.CacheConstants;
import com.pig4cloud.pig.common.core.constant.SecurityConstants;
import io.springboot.captcha.ArithmeticCaptcha;
@ -38,6 +39,10 @@ public class ImageCodeEndpoint {
public void image(String randomStr, HttpServletResponse response) {
ArithmeticCaptcha captcha = new ArithmeticCaptcha(DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT);
if (Validator.isMobile(randomStr)) {
return;
}
String result = captcha.text();
redisTemplate.opsForValue()
.set(CacheConstants.DEFAULT_CODE_KEY + randomStr, result, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);