perf:验证码校验调整

This commit is contained in:
曾文豪
2023-01-09 16:09:29 +08:00
parent 7c6ab72016
commit 37926c39c1

View File

@@ -61,24 +61,21 @@ public class TimedCacheService {
* @param session
* @param value
*/
public void setImageCode(String session, String value) {
putCache(session, value);
public void setImageCode(String captcha, String value) {
putCache(captcha, value);
}
/**
* 验证 图片验证码
* 该验证兼容V2的图片验证码
*
* @param session
*/
public void verifyImage(String session, String value) {
public void verifyImage(String value) {
String captchaKey = ServletUtil.getHeader(ServletKit.getRequest(), "captcha", "utf-8");
String cache = !StrUtil.isEmpty(captchaKey) ? getCache(captchaKey) : getCache(session);
String cache = getCache(captchaKey);
if (StrUtil.isEmpty(cache) || !StrUtil.equals(cache, value)) {
throw new ApiException("验证码不正确");
}
clearByKey(session);
clearByKey(captchaKey);
}