【8.0.4】【sys】更新拖拽验证码过期时间

pull/60/head
fengshuonan 2023-11-25 09:03:55 +08:00
parent 8846987c19
commit 8780aa8904
3 changed files with 9 additions and 3 deletions

View File

@ -37,4 +37,9 @@ public interface CaptchaConstants {
*/
String CAPTCHA_CACHE_KEY_PREFIX = "CAPTCHA_KEY";
/**
*
*/
Long DRAG_CAPTCHA_IMG_EXP_SECONDS = 120L;
}

View File

@ -31,6 +31,7 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.security.api.DragCaptchaApi;
import cn.stylefeng.roses.kernel.security.api.constants.CaptchaConstants;
import cn.stylefeng.roses.kernel.security.api.exception.SecurityException;
import cn.stylefeng.roses.kernel.security.api.exception.enums.SecurityExceptionEnum;
import cn.stylefeng.roses.kernel.security.api.pojo.DragCaptchaImageDTO;
@ -63,11 +64,10 @@ public class DragCaptchaService implements DragCaptchaApi {
// 缓存x轴坐标
String verKey = IdUtil.simpleUUID();
Integer verValue = dragCaptchaImageDTO.getLocationX();
cacheOperatorApi.put(verKey, verValue.toString());
cacheOperatorApi.put(verKey, verValue.toString(), CaptchaConstants.DRAG_CAPTCHA_IMG_EXP_SECONDS);
// 清空x轴坐标
dragCaptchaImageDTO.setKey(verKey);
// dragCaptchaImageDTO.setLocationX(null);
return dragCaptchaImageDTO;
} catch (IOException e) {

View File

@ -5,6 +5,7 @@ import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.cache.api.constants.CacheConstants;
import cn.stylefeng.roses.kernel.security.api.constants.CaptchaConstants;
import cn.stylefeng.roses.kernel.security.captcha.cache.CaptchaMemoryCache;
import cn.stylefeng.roses.kernel.security.count.cache.CountValidateMemoryCache;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
@ -30,7 +31,7 @@ public class SecurityMemoryCacheAutoConfiguration {
@Bean("captchaCache")
public CacheOperatorApi<String> captchaMemoryCache() {
// 验证码过期时间 120秒
TimedCache<String, String> timedCache = CacheUtil.newTimedCache(1000 * 120);
TimedCache<String, String> timedCache = CacheUtil.newTimedCache(1000 * CaptchaConstants.DRAG_CAPTCHA_IMG_EXP_SECONDS);
return new CaptchaMemoryCache(timedCache);
}