diff --git a/db_manager.py b/db_manager.py index 85b45f4..5e648f4 100644 --- a/db_manager.py +++ b/db_manager.py @@ -342,7 +342,8 @@ class DBManager: # 插入默认系统设置(不包括管理员密码,由reply_server.py初始化) cursor.execute(''' INSERT OR IGNORE INTO system_settings (key, value, description) VALUES - ('theme_color', 'blue', '主题颜色') + ('theme_color', 'blue', '主题颜色'), + ('registration_enabled', 'true', '是否开启用户注册') ''') # 检查并升级数据库 diff --git a/reply_server.py b/reply_server.py index b6b64b6..eac4295 100644 --- a/reply_server.py +++ b/reply_server.py @@ -85,6 +85,8 @@ class LoginResponse(BaseModel): token: Optional[str] = None message: str user_id: Optional[int] = None + username: Optional[str] = None + is_admin: Optional[bool] = None class ChangePasswordRequest(BaseModel): @@ -397,6 +399,33 @@ async def login_page(): # 注册页面路由 @app.get('/register.html', response_class=HTMLResponse) async def register_page(): + # 检查注册是否开启 + from db_manager import db_manager + registration_enabled = db_manager.get_system_setting('registration_enabled') + if registration_enabled != 'true': + return HTMLResponse(''' + + +
+