feat: 添加邮件功能第五阶段 - 用户邮箱绑定

1. 添加邮箱绑定验证邮件模板 (templates/email/bind_email.html)
2. 在email_service.py中添加:
   - send_bind_email_verification() 发送绑定验证邮件
   - verify_bind_email_token() 验证绑定Token
3. 在database.py中添加:
   - update_user_email() 更新用户邮箱
4. 在app.py中添加API:
   - GET /api/user/email - 获取用户邮箱信息
   - POST /api/user/bind-email - 发送绑定验证邮件
   - GET /api/verify-bind-email/<token> - 验证绑定Token
   - POST /api/user/unbind-email - 解绑邮箱
5. 更新templates/index.html:
   - 将"修改密码"弹窗改为"个人设置"
   - 添加邮箱绑定/解绑功能UI
   - 显示邮箱状态(未绑定/待验证/已验证)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-11 22:20:29 +08:00
parent f020a9c6d9
commit 7298cffe5e
5 changed files with 463 additions and 14 deletions

View File

@@ -830,6 +830,19 @@ def get_user_by_email(email):
return dict(user) if user else None
def update_user_email(user_id, email, verified=False):
"""更新用户邮箱"""
with db_pool.get_db() as conn:
cursor = conn.cursor()
cursor.execute('''
UPDATE users
SET email = ?, email_verified = ?
WHERE id = ?
''', (email, int(verified), user_id))
conn.commit()
return cursor.rowcount > 0
def get_all_users():
"""获取所有用户"""
with db_pool.get_db() as conn: