From 91d9c04a3df1d07203b354532d2ae4e8551c9546 Mon Sep 17 00:00:00 2001 From: xfy Date: Tue, 26 May 2026 16:16:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BD=BF=E7=94=A8=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 登录查询同时匹配 username 或 email - 更新登录页标签和 placeholder Co-Authored-By: Claude Opus 4.7 (1M context) --- src/api/auth.rs | 2 +- src/pages/login.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/auth.rs b/src/api/auth.rs index c0b2de8..c27768b 100644 --- a/src/api/auth.rs +++ b/src/api/auth.rs @@ -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 diff --git a/src/pages/login.rs b/src/pages/login.rs index 6b5d1e3..d47063b 100644 --- a/src/pages/login.rs +++ b/src/pages/login.rs @@ -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()), }