Skip to content

Commit

Permalink
refactor: 优化图形验证码使用及部分配置
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Feb 4, 2024
1 parent c9cda12 commit a50d857
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import top.charles7c.continew.admin.common.constant.CacheConstants;
import top.charles7c.continew.admin.common.model.resp.CaptchaResp;
import top.charles7c.continew.starter.cache.redisson.util.RedisUtils;
import top.charles7c.continew.starter.captcha.graphic.core.GraphicCaptchaService;
import top.charles7c.continew.starter.core.autoconfigure.project.ProjectProperties;
import top.charles7c.continew.starter.core.util.TemplateUtils;
import top.charles7c.continew.starter.core.util.validate.CheckUtils;
Expand Down Expand Up @@ -74,7 +75,7 @@
public class CaptchaController {

private final CaptchaService behaviorCaptchaService;
private final Captcha graphicCaptchaService;
private final GraphicCaptchaService graphicCaptchaService;
private final ProjectProperties projectProperties;
private final CaptchaProperties captchaProperties;

Expand All @@ -99,9 +100,9 @@ public R<Object> checkBehaviorCaptcha(@RequestBody CaptchaVO captchaReq) {
public R<CaptchaResp> getImageCaptcha() {
String uuid = IdUtil.fastUUID();
String captchaKey = CacheConstants.CAPTCHA_KEY_PREFIX + uuid;
RedisUtils.set(captchaKey, graphicCaptchaService.text(), Duration.ofMinutes(captchaProperties
.getExpirationInMinutes()));
return R.ok(CaptchaResp.builder().uuid(uuid).img(graphicCaptchaService.toBase64()).build());
Captcha captcha = graphicCaptchaService.getCaptcha();
RedisUtils.set(captchaKey, captcha.text(), Duration.ofMinutes(captchaProperties.getExpirationInMinutes()));
return R.ok(CaptchaResp.builder().uuid(uuid).img(captcha.toBase64()).build());
}

@Operation(summary = "获取邮箱验证码", description = "发送验证码到指定邮箱")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ continew-starter.captcha:
water-mark: ${project.app-name}
## 图形验证码
graphic:
enabled: true
# 类型
type: SPEC
# 内容长度
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ continew-starter.captcha:
water-mark: ${project.app-name}
## 图形验证码
graphic:
enabled: true
# 类型
type: SPEC
# 内容长度
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ project:

--- ### 日志配置
continew-starter.log:
enabled: true
# 包含信息
include:
- DESCRIPTION
Expand Down

0 comments on commit a50d857

Please sign in to comment.