支持使用邮箱登录
- 登录查询同时匹配 username 或 email - 更新登录页标签和 placeholder Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8b9c6aa83d
commit
91d9c04a3d
@ -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
|
||||
|
||||
@ -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()),
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user