fix: 修复邮箱绑定验证错误及多项改进
1. 修复email_verified字段缺失导致的500错误 2. 将邮件主题从"知识管理平台"改为"自动化学习" 3. 增大验证码字体(28->42)和图片尺寸(120x40->160x60) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
42
database.py
42
database.py
@@ -834,6 +834,13 @@ def update_user_email(user_id, email, verified=False):
|
||||
"""更新用户邮箱"""
|
||||
with db_pool.get_db() as conn:
|
||||
cursor = conn.cursor()
|
||||
# 先检查email_verified字段是否存在,不存在则添加
|
||||
try:
|
||||
cursor.execute('SELECT email_verified FROM users LIMIT 1')
|
||||
except:
|
||||
cursor.execute('ALTER TABLE users ADD COLUMN email_verified INTEGER DEFAULT 0')
|
||||
conn.commit()
|
||||
|
||||
cursor.execute('''
|
||||
UPDATE users
|
||||
SET email = ?, email_verified = ?
|
||||
@@ -843,6 +850,41 @@ def update_user_email(user_id, email, verified=False):
|
||||
return cursor.rowcount > 0
|
||||
|
||||
|
||||
def update_user_email_notify(user_id, enabled):
|
||||
"""更新用户邮件通知偏好"""
|
||||
with db_pool.get_db() as conn:
|
||||
cursor = conn.cursor()
|
||||
# 先检查字段是否存在
|
||||
try:
|
||||
cursor.execute('SELECT email_notify_enabled FROM users LIMIT 1')
|
||||
except:
|
||||
cursor.execute('ALTER TABLE users ADD COLUMN email_notify_enabled INTEGER DEFAULT 1')
|
||||
conn.commit()
|
||||
|
||||
cursor.execute('''
|
||||
UPDATE users
|
||||
SET email_notify_enabled = ?
|
||||
WHERE id = ?
|
||||
''', (int(enabled), user_id))
|
||||
conn.commit()
|
||||
return cursor.rowcount > 0
|
||||
|
||||
|
||||
def get_user_email_notify(user_id):
|
||||
"""获取用户邮件通知偏好(默认开启)"""
|
||||
with db_pool.get_db() as conn:
|
||||
cursor = conn.cursor()
|
||||
# 先检查字段是否存在
|
||||
try:
|
||||
cursor.execute('SELECT email_notify_enabled FROM users WHERE id = ?', (user_id,))
|
||||
row = cursor.fetchone()
|
||||
if row is None:
|
||||
return True
|
||||
return bool(row[0]) if row[0] is not None else True
|
||||
except:
|
||||
return True # 字段不存在时默认开启
|
||||
|
||||
|
||||
def get_all_users():
|
||||
"""获取所有用户"""
|
||||
with db_pool.get_db() as conn:
|
||||
|
||||
Reference in New Issue
Block a user