mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-22 12:48:58 +08:00
refactor(security): Validator.isMobile randomStr
This commit is contained in:
parent
011441b9f7
commit
6affe64e92
@ -1,5 +1,6 @@
|
|||||||
package com.pig4cloud.pig.auth.endpoint;
|
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.CacheConstants;
|
||||||
import com.pig4cloud.pig.common.core.constant.SecurityConstants;
|
import com.pig4cloud.pig.common.core.constant.SecurityConstants;
|
||||||
import io.springboot.captcha.ArithmeticCaptcha;
|
import io.springboot.captcha.ArithmeticCaptcha;
|
||||||
@ -38,6 +39,10 @@ public class ImageCodeEndpoint {
|
|||||||
public void image(String randomStr, HttpServletResponse response) {
|
public void image(String randomStr, HttpServletResponse response) {
|
||||||
ArithmeticCaptcha captcha = new ArithmeticCaptcha(DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT);
|
ArithmeticCaptcha captcha = new ArithmeticCaptcha(DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT);
|
||||||
|
|
||||||
|
if (Validator.isMobile(randomStr)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String result = captcha.text();
|
String result = captcha.text();
|
||||||
redisTemplate.opsForValue()
|
redisTemplate.opsForValue()
|
||||||
.set(CacheConstants.DEFAULT_CODE_KEY + randomStr, result, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
|
.set(CacheConstants.DEFAULT_CODE_KEY + randomStr, result, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
|
||||||
|
Loading…
Reference in New Issue
Block a user