mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-10 20:57:14 +08:00
refactor: 优化邮件配置
This commit is contained in:
@@ -48,6 +48,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import top.continew.admin.common.config.properties.CaptchaProperties;
|
||||
import top.continew.admin.common.constant.CacheConstants;
|
||||
import top.continew.admin.common.model.resp.CaptchaResp;
|
||||
import top.continew.admin.system.service.OptionService;
|
||||
import top.continew.starter.cache.redisson.util.RedisUtils;
|
||||
import top.continew.starter.captcha.graphic.core.GraphicCaptchaService;
|
||||
import top.continew.starter.core.autoconfigure.project.ProjectProperties;
|
||||
@@ -77,10 +78,11 @@ import java.util.Map;
|
||||
@RequestMapping("/captcha")
|
||||
public class CaptchaController {
|
||||
|
||||
private final CaptchaService behaviorCaptchaService;
|
||||
private final GraphicCaptchaService graphicCaptchaService;
|
||||
private final ProjectProperties projectProperties;
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final CaptchaService behaviorCaptchaService;
|
||||
private final GraphicCaptchaService graphicCaptchaService;
|
||||
private final OptionService optionService;
|
||||
|
||||
@Log(ignore = true)
|
||||
@Operation(summary = "获取行为验证码", description = "获取行为验证码(Base64编码)")
|
||||
@@ -127,7 +129,11 @@ public class CaptchaController {
|
||||
String captcha = RandomUtil.randomNumbers(captchaMail.getLength());
|
||||
// 发送验证码
|
||||
Long expirationInMinutes = captchaMail.getExpirationInMinutes();
|
||||
Map<String, String> siteConfig = optionService.getByCategory("SITE");
|
||||
String content = TemplateUtils.render(captchaMail.getTemplatePath(), Dict.create()
|
||||
.set("siteUrl", projectProperties.getUrl())
|
||||
.set("siteTitle", siteConfig.get("SITE_TITLE"))
|
||||
.set("siteCopyright", siteConfig.get("SITE_COPYRIGHT"))
|
||||
.set("captcha", captcha)
|
||||
.set("expiration", expirationInMinutes));
|
||||
MailUtils.sendHtml(email, "【%s】邮箱验证码".formatted(projectProperties.getName()), content);
|
||||
|
@@ -123,11 +123,11 @@ VALUES
|
||||
(12, 'PASSWORD', '密码最小长度', 'PASSWORD_MIN_LENGTH', NULL, '8', '取值范围为 8-32。', NULL, NULL),
|
||||
(13, 'PASSWORD', '密码是否允许包含正反序账号名', 'PASSWORD_ALLOW_CONTAIN_USERNAME', NULL, '1', NULL, NULL, NULL),
|
||||
(14, 'PASSWORD', '密码是否必须包含特殊字符', 'PASSWORD_CONTAIN_SPECIAL_CHARACTERS', NULL, '0', NULL, NULL, NULL),
|
||||
(15, 'MAIL', '发件人邮箱', 'MAIL_FROM', NULL, 'charles7c@126.com', NULL, NULL, NULL),
|
||||
(16, 'MAIL', 'SMTP服务器', 'MAIL_SMTP_HOST', NULL, 'smtp.126.com', NULL, NULL, NULL),
|
||||
(17, 'MAIL', 'SMTP端口', 'MAIL_SMTP_PORT', NULL, '465', NULL, NULL, NULL),
|
||||
(18, 'MAIL', 'SMTP用户名', 'MAIL_SMTP_USERNAME', NULL, 'charles7c@126.com', NULL, NULL, NULL),
|
||||
(19, 'MAIL', 'SMTP密码', 'MAIL_SMTP_PASSWORD', NULL, NULL, NULL, NULL, NULL),
|
||||
(15, 'MAIL', '发送协议', 'MAIL_PROTOCOL', NULL, 'smtp', NULL, NULL, NULL),
|
||||
(16, 'MAIL', '服务器地址', 'MAIL_HOST', NULL, 'smtp.126.com', NULL, NULL, NULL),
|
||||
(17, 'MAIL', '服务器端口', 'MAIL_PORT', NULL, '465', NULL, NULL, NULL),
|
||||
(18, 'MAIL', '用户名', 'MAIL_USERNAME', NULL, 'charles7c@126.com', NULL, NULL, NULL),
|
||||
(19, 'MAIL', '密码', 'MAIL_PASSWORD', NULL, NULL, NULL, NULL, NULL),
|
||||
(20, 'MAIL', '是否启用SSL', 'MAIL_SSL_ENABLED', NULL, '1', NULL, NULL, NULL),
|
||||
(21, 'MAIL', 'SSL端口', 'MAIL_SSL_PORT', NULL, '465', NULL, NULL, NULL);
|
||||
|
||||
|
@@ -123,11 +123,11 @@ VALUES
|
||||
(12, 'PASSWORD', '密码最小长度', 'PASSWORD_MIN_LENGTH', NULL, '8', '取值范围为 8-32。', NULL, NULL),
|
||||
(13, 'PASSWORD', '密码是否允许包含正反序账号名', 'PASSWORD_ALLOW_CONTAIN_USERNAME', NULL, '1', NULL, NULL, NULL),
|
||||
(14, 'PASSWORD', '密码是否必须包含特殊字符', 'PASSWORD_CONTAIN_SPECIAL_CHARACTERS', NULL, '0', NULL, NULL, NULL),
|
||||
(15, 'MAIL', '发件人邮箱', 'MAIL_FROM', NULL, 'charles7c@126.com', NULL, NULL, NULL),
|
||||
(16, 'MAIL', 'SMTP服务器', 'MAIL_SMTP_HOST', NULL, 'smtp.126.com', NULL, NULL, NULL),
|
||||
(17, 'MAIL', 'SMTP端口', 'MAIL_SMTP_PORT', NULL, '465', NULL, NULL, NULL),
|
||||
(18, 'MAIL', 'SMTP用户名', 'MAIL_SMTP_USERNAME', NULL, 'charles7c@126.com', NULL, NULL, NULL),
|
||||
(19, 'MAIL', 'SMTP密码', 'MAIL_SMTP_PASSWORD', NULL, NULL, NULL, NULL, NULL),
|
||||
(15, 'MAIL', '发送协议', 'MAIL_PROTOCOL', NULL, 'smtp', NULL, NULL, NULL),
|
||||
(16, 'MAIL', '服务器地址', 'MAIL_HOST', NULL, 'smtp.126.com', NULL, NULL, NULL),
|
||||
(17, 'MAIL', '服务器端口', 'MAIL_PORT', NULL, '465', NULL, NULL, NULL),
|
||||
(18, 'MAIL', '用户名', 'MAIL_USERNAME', NULL, 'charles7c@126.com', NULL, NULL, NULL),
|
||||
(19, 'MAIL', '密码', 'MAIL_PASSWORD', NULL, NULL, NULL, NULL, NULL),
|
||||
(20, 'MAIL', '是否启用SSL', 'MAIL_SSL_ENABLED', NULL, '1', NULL, NULL, NULL),
|
||||
(21, 'MAIL', 'SSL端口', 'MAIL_SSL_PORT', NULL, '465', NULL, NULL, NULL);
|
||||
|
||||
|
@@ -13,22 +13,22 @@
|
||||
<div style="margin: 0 auto; text-align: left; position: relative; border-radius: 5px; border-collapse: collapse; box-shadow: rgb(153, 153, 153) 0px 0px 5px; background: #fff; font-family: 微软雅黑, 黑体, sans-serif; font-size: 14px; line-height: 1.5;">
|
||||
<div style="height: 29px; line-height: 25px; padding: 15px 30px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #307AF2; background: #00308f; border-radius: 5px 5px 0 0;">
|
||||
<div style="font-size: 24px; font-weight: bolder; color: #fff; display: inline-flex; align-items: center;">
|
||||
<a href="https://admin.continew.top/">
|
||||
<img src="https://admin.continew.top/logo.svg" alt="ContiNew Admin" style="vertical-align: middle;">
|
||||
<a href="${siteUrl}">
|
||||
<img src="https://admin.continew.top/logo.svg" alt="${siteTitle}" style="vertical-align: middle;">
|
||||
</a>
|
||||
<a href="https://admin.continew.top/" style="margin-left: 4px; text-decoration: none; color: #fff;">ContiNew Admin</a>
|
||||
<a href="${siteUrl}" style="margin-left: 4px; text-decoration: none; color: #fff;">${siteTitle}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div style="word-break: break-word;">
|
||||
<div style="border-radius: 5px; padding: 25px 30px 11px; background-color: #fff; opacity: 0.8;">
|
||||
<h2 style="margin: 5px 0; font-size: 18px; line-height: 22px; color: #333;">亲爱的用户:</h2>
|
||||
<p>
|
||||
您好!感谢您使用 <a href="https://github.com/Charles7c/continew-admin" style="color: #333;">ContiNew Admin</a>,本次请求的验证码为:<span style="font-size: 16px; color: #ff8c00;">${captcha}</span>,请在 ${expiration} 分钟内使用此验证码完成验证。
|
||||
您好!感谢您使用 <a href="${siteUrl}" style="color: #333;">${siteTitle}</a>,本次请求的验证码为:<span style="font-size: 16px; color: #ff8c00;">${captcha}</span>,请在 ${expiration} 分钟内使用此验证码完成验证。
|
||||
</p>
|
||||
<br>
|
||||
<h2 style="margin: 5px 0; font-size: 18px; line-height: 22px; color: #333;">Dear user:</h2>
|
||||
<p>
|
||||
Hello! Thanks for using ContiNew Admin, The verification code for this request is: <span style="font-size: 16px; color: #ff8c00;">${captcha}</span>, please use this verification code to complete the verification within ${expiration} minutes.
|
||||
Hello! Thanks for using ${siteTitle}, The verification code for this request is: <span style="font-size: 16px; color: #ff8c00;">${captcha}</span>, please use this verification code to complete the verification within ${expiration} minutes.
|
||||
</p>
|
||||
<div style="width: 100%; margin: 0 auto;">
|
||||
<div style="padding: 10px 10px 0; border-top: 1px solid #ccc; color: #747474; margin-bottom: 20px; line-height: 1.3em; font-size: 12px;">
|
||||
@@ -36,7 +36,7 @@
|
||||
若非本人操作,请忽略此邮件。此邮件由系统自动发送,请勿直接回复该邮件。<br>
|
||||
Please ignore this email if not by yourself. This email is sent automatically by the system, please do not reply to this email directly.
|
||||
</p>
|
||||
<p>Copyright © 2022-present Charles7c</p>
|
||||
<p>${siteCopyright}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user