支持使用邮箱登录

- 登录查询同时匹配 username 或 email
- 更新登录页标签和 placeholder

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-26 16:16:40 +08:00
parent 8b9c6aa83d
commit 91d9c04a3d
2 changed files with 3 additions and 3 deletions

View File

@ -131,7 +131,7 @@ pub async fn login(
let row = match client
.query_opt(
"SELECT id, username, email, password_hash, role, created_at FROM users WHERE username = $1",
"SELECT id, username, email, password_hash, role, created_at FROM users WHERE username = $1 OR email = $1",
&[&username],
)
.await

View File

@ -78,12 +78,12 @@ pub fn LoginPage() -> Element {
div { class: "space-y-4",
div {
label { class: "block text-sm font-medium text-gray-700 dark:text-[#9b9c9d] mb-1",
"用户名"
"用户名 / 邮箱"
}
input {
class: "w-full px-4 py-2 border border-gray-200 dark:border-[#333] rounded-lg bg-white dark:bg-[#2e2e33] text-gray-900 dark:text-[#dadadb] focus:outline-none focus:border-gray-400 dark:focus:border-gray-600",
r#type: "text",
placeholder: "用户名",
placeholder: "用户名或邮箱",
value: username(),
oninput: move |e| username.set(e.value()),
}