v4.1 管理员邮箱绑定与SMTP找回密码
1. users 表新增 email 列,管理员添加/编辑支持绑定邮箱,修改密码页支持自助绑定 2. 新增 SMTP 邮件发送工具与配置(FRONTEND_URL/SMTP_* 等) 3. 新增忘记密码/重置密码公开接口与页面:一次性令牌、30分钟有效、请求限流、重置后强制重新登录 4. 登录与 /api/auth/me 返回邮箱并同步 PHP Session 5. 版本升级至4.1(sql/upgrades/v4.1.sql)
This commit is contained in:
1 parent
3588b4c28c
commit
058dee9dc4
31 files changed
+762
-34
No files matched your search
@@ -53,6 +53,7 @@ class AddAdminRequest(BaseModel):
|
||||
real_name: str = Field(..., min_length=1, max_length=50, description="真实姓名")
|
||||
password: Optional[str] = Field(None, min_length=6, max_length=50, description="密码(不填则自动生成)")
|
||||
group_id: int = Field(..., gt=0, description="权限组ID")
|
||||
email: Optional[str] = Field(None, max_length=100, description="绑定邮箱(用于找回密码)")
|
||||
subject_id: Optional[int] = Field(None, gt=0, description="科目ID(科代表需要)")
|
||||
|
||||
|
||||
@@ -87,6 +88,7 @@ class UpdateAdminRequest(BaseModel):
|
||||
"""更新管理员请求"""
|
||||
real_name: str = Field(..., min_length=1, max_length=50, description="真实姓名")
|
||||
group_id: int = Field(..., gt=0, description="权限组ID")
|
||||
email: Optional[str] = Field(None, max_length=100, description="绑定邮箱(留空解除绑定)")
|
||||
|
||||
|
||||
class PermissionGroupRequest(BaseModel):
|
||||
|
||||
+19
-1
@@ -52,4 +52,22 @@ class UserInfo(BaseModel):
|
||||
user_type: str
|
||||
student_id: Optional[int] = None
|
||||
role: Optional[str] = None
|
||||
need_change_password: bool
|
||||
email: Optional[str] = None
|
||||
need_change_password: bool
|
||||
|
||||
|
||||
class ForgotPasswordRequest(BaseModel):
|
||||
"""忘记密码请求"""
|
||||
username: str = Field(..., min_length=1, max_length=50, description="用户名")
|
||||
|
||||
|
||||
class ResetPasswordRequest(BaseModel):
|
||||
"""通过邮件令牌重置密码请求"""
|
||||
token: str = Field(..., min_length=10, max_length=200, description="重置令牌")
|
||||
new_password: str = Field(..., min_length=6, max_length=20, description="新密码")
|
||||
|
||||
|
||||
class BindEmailRequest(BaseModel):
|
||||
"""绑定/修改邮箱请求"""
|
||||
password: str = Field(..., min_length=1, max_length=50, description="当前密码")
|
||||
email: str = Field(default="", max_length=100, description="新邮箱(留空解除绑定)")
|
||||
Reference in new issue
Block a user