mirror of https://gitee.com/stylefeng/roses
【8.0.4】【sys】更新拖拽验证码过期时间
parent
8846987c19
commit
8780aa8904
|
@ -37,4 +37,9 @@ public interface CaptchaConstants {
|
||||||
*/
|
*/
|
||||||
String CAPTCHA_CACHE_KEY_PREFIX = "CAPTCHA_KEY";
|
String CAPTCHA_CACHE_KEY_PREFIX = "CAPTCHA_KEY";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拖拽验证码缓存过期时间
|
||||||
|
*/
|
||||||
|
Long DRAG_CAPTCHA_IMG_EXP_SECONDS = 120L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||||
import cn.stylefeng.roses.kernel.security.api.DragCaptchaApi;
|
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.SecurityException;
|
||||||
import cn.stylefeng.roses.kernel.security.api.exception.enums.SecurityExceptionEnum;
|
import cn.stylefeng.roses.kernel.security.api.exception.enums.SecurityExceptionEnum;
|
||||||
import cn.stylefeng.roses.kernel.security.api.pojo.DragCaptchaImageDTO;
|
import cn.stylefeng.roses.kernel.security.api.pojo.DragCaptchaImageDTO;
|
||||||
|
@ -63,11 +64,10 @@ public class DragCaptchaService implements DragCaptchaApi {
|
||||||
// 缓存x轴坐标
|
// 缓存x轴坐标
|
||||||
String verKey = IdUtil.simpleUUID();
|
String verKey = IdUtil.simpleUUID();
|
||||||
Integer verValue = dragCaptchaImageDTO.getLocationX();
|
Integer verValue = dragCaptchaImageDTO.getLocationX();
|
||||||
cacheOperatorApi.put(verKey, verValue.toString());
|
cacheOperatorApi.put(verKey, verValue.toString(), CaptchaConstants.DRAG_CAPTCHA_IMG_EXP_SECONDS);
|
||||||
|
|
||||||
// 清空x轴坐标
|
// 清空x轴坐标
|
||||||
dragCaptchaImageDTO.setKey(verKey);
|
dragCaptchaImageDTO.setKey(verKey);
|
||||||
// dragCaptchaImageDTO.setLocationX(null);
|
|
||||||
|
|
||||||
return dragCaptchaImageDTO;
|
return dragCaptchaImageDTO;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.cache.CacheUtil;
|
||||||
import cn.hutool.cache.impl.TimedCache;
|
import cn.hutool.cache.impl.TimedCache;
|
||||||
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||||
import cn.stylefeng.roses.kernel.cache.api.constants.CacheConstants;
|
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.captcha.cache.CaptchaMemoryCache;
|
||||||
import cn.stylefeng.roses.kernel.security.count.cache.CountValidateMemoryCache;
|
import cn.stylefeng.roses.kernel.security.count.cache.CountValidateMemoryCache;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||||
|
@ -30,7 +31,7 @@ public class SecurityMemoryCacheAutoConfiguration {
|
||||||
@Bean("captchaCache")
|
@Bean("captchaCache")
|
||||||
public CacheOperatorApi<String> captchaMemoryCache() {
|
public CacheOperatorApi<String> captchaMemoryCache() {
|
||||||
// 验证码过期时间 120秒
|
// 验证码过期时间 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);
|
return new CaptchaMemoryCache(timedCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue