From 6affe64e92500ff4b5ba8ebdeef005f98cf218e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= <2270033969@qq.com> Date: Fri, 2 Aug 2024 19:14:09 +0800 Subject: [PATCH] refactor(security): Validator.isMobile randomStr --- .../com/pig4cloud/pig/auth/endpoint/ImageCodeEndpoint.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/ImageCodeEndpoint.java b/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/ImageCodeEndpoint.java index 42bed102..6197f134 100644 --- a/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/ImageCodeEndpoint.java +++ b/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/ImageCodeEndpoint.java @@ -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);