Commit e005e254 authored by 郑磊's avatar 郑磊

增加回显验证数据接口

parent 15c701dd
......@@ -104,6 +104,18 @@ public class CaptchaApplication extends DefaultImageCaptchaApplication {
);
}
/**
* 获取二次校验数据
*
* @param key 验证码key
* @return 二次校验数据
*/
public Map<String, Object> getSecondaryData(String key) {
if (key == null || key.isEmpty()) return null;
var secondary = prop.getSecondary();
return getCacheStore().getAndRemoveCache(secondary.getKeyPrefix().concat(":").concat(key));
}
/**
* 二次校验(使用)验证码
*
......@@ -114,12 +126,7 @@ public class CaptchaApplication extends DefaultImageCaptchaApplication {
if (data == null) return false;
//读取二次校验数据
var secondary = prop.getSecondary();
var verification = getCacheStore().getAndRemoveCache(secondary.getKeyPrefix().concat(":").concat(data.getKey()));
if (verification == null) {
//如果没有校验数据,那么视为校验失败
return false;
}
var verification = getSecondaryData(data.getKey());
//如果传入了ip,那就校验ip
String ip = data.getIp();
......
......@@ -119,4 +119,16 @@ public class CaptchaController {
return Response.success();
}
@RequestMapping("/verifyInfo")
public Response<?> verifyCaptcha(
@RequestParam(name = "key") String key
) {
var data = imageCaptchaApplication.getSecondaryData(key);
if (data == null) {
return Response.fail("未验证的数据");
} else {
return Response.success(data);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment