Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ rand = "0.8"
clap = { version = "4", features = ["derive", "env"] }

# 注册邮箱验证码发信(rant 2026-08-19T14:36:19:方案 B 完整验证码)
lettre = { version = "0.11", default-features = false, features = ["builder", "smtp-transport", "rustls-tls", "hostname", "pool"] }
lettre = { version = "0.11", default-features = false, features = ["builder", "smtp-transport", "rustls-tls", "hostname"] }
3 changes: 3 additions & 0 deletions src/mail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//! `SmtpTransport::builder_dangerous(...).tls(Tls::Opportunistic(...))`。

use anyhow::{Context, Result};
use std::time::Duration;

use crate::config::Mail;
use lettre::Transport;
Expand Down Expand Up @@ -61,6 +62,8 @@ pub fn send_verification_code(cfg: &Mail, to: &str, code: &str) -> Result<()> {
.with_context(|| format!("SMTP 服务器不可用: {}", cfg.smtp_host))?
.port(cfg.smtp_port)
.credentials(creds)
// 显式 15s 超时:避免无 pool 时挂住/长等(rant 2026-08-21T14:08:03)
.timeout(Some(Duration::from_secs(15)))
.build();
mailer.send(&email).map_err(|e| {
log::error!("SMTP 发送验证码到 {to} 失败: {e:?}");
Expand Down
4 changes: 3 additions & 1 deletion ui/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2673,7 +2673,9 @@
const email = $("#verify-email").value.trim();
if (!email) return;
const b = $("#resend-btn");
const orig = b.textContent;
b.disabled = true;
b.textContent = T("verify.sending"); // 发送中反馈(rant 2026-08-21T14:08:03 补充验收)
try {
const r = await api.post("/api/auth/resend-code", { email });
if (r.dev_code) { toast(T("verify.devCode") + ": " + r.dev_code, "info"); }
Expand All @@ -2682,7 +2684,7 @@
const m = (err && err.message) ? I18n.mapErr(err.message) : T("verify.err.fail");
toast(m, "error");
} finally {
setTimeout(() => { b.disabled = false; }, 1000);
setTimeout(() => { b.disabled = false; b.textContent = orig; }, 300);
}
});

Expand Down
2 changes: 2 additions & 0 deletions ui/js/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"verify.code": "验证码",
"verify.submit": "验证并激活",
"verify.resend": "重新发送",
"verify.sending": "发送中…",
"verify.sent": "验证码已发送到邮箱",
"verify.ok": "注册成功,请登录",
"verify.devCode": "[dev] 验证码",
Expand Down Expand Up @@ -759,6 +760,7 @@
"verify.code": "Verification code",
"verify.submit": "Verify & Activate",
"verify.resend": "Resend",
"verify.sending": "Sending…",
"verify.sent": "Verification code sent to your email",
"verify.ok": "Registered successfully, please sign in",
"verify.devCode": "[dev] Code",
Expand Down
Loading