v1.7版本更新
This commit is contained in:
@@ -88,6 +88,7 @@ class AdminService:
|
||||
student_no = student.get("student_no", "").strip()
|
||||
name = student.get("name", "").strip()
|
||||
parent_phone = student.get("parent_phone", "").strip()
|
||||
dormitory_number = student.get("dormitory_number", "").strip() if student.get("dormitory_number") else None
|
||||
password = student.get("password", "").strip()
|
||||
|
||||
if not student_no or not name:
|
||||
@@ -113,6 +114,7 @@ class AdminService:
|
||||
student_no=student_no,
|
||||
name=name,
|
||||
parent_phone=parent_phone if parent_phone else None,
|
||||
dormitory_number=dormitory_number,
|
||||
initial_points=initial_points
|
||||
)
|
||||
existing_student_nos.add(student_no)
|
||||
@@ -162,7 +164,8 @@ class AdminService:
|
||||
name: str,
|
||||
parent_phone: Optional[str],
|
||||
operator_id: int,
|
||||
initial_points: int = 60
|
||||
initial_points: int = 60,
|
||||
dormitory_number: Optional[str] = None
|
||||
) -> Dict[str, Any]:
|
||||
"""新增学生"""
|
||||
if not security.validate_student_no(student_no):
|
||||
@@ -179,6 +182,7 @@ class AdminService:
|
||||
student_no=student_no,
|
||||
name=name,
|
||||
parent_phone=parent_phone if parent_phone else None,
|
||||
dormitory_number=dormitory_number,
|
||||
initial_points=initial_points
|
||||
)
|
||||
|
||||
@@ -248,14 +252,14 @@ class AdminService:
|
||||
return {"admins": admins}
|
||||
|
||||
@staticmethod
|
||||
async def update_student(student_id: int, name: str = None, parent_phone: str = None) -> Dict[str, Any]:
|
||||
async def update_student(student_id: int, name: str = None, parent_phone: str = None, dormitory_number: str = None) -> Dict[str, Any]:
|
||||
"""编辑学生信息"""
|
||||
try:
|
||||
student = await StudentModel.get_by_id(student_id)
|
||||
if not student:
|
||||
return {"success": False, "message": "学生不存在"}
|
||||
|
||||
result = await StudentModel.update(student_id, name=name, parent_phone=parent_phone)
|
||||
result = await StudentModel.update(student_id, name=name, parent_phone=parent_phone, dormitory_number=dormitory_number)
|
||||
if result:
|
||||
return {"success": True, "message": "学生信息更新成功"}
|
||||
return {"success": False, "message": "更新失败"}
|
||||
|
||||
@@ -48,11 +48,19 @@ class AuthService:
|
||||
return {"success": False, "message": "用户名或密码错误"}
|
||||
|
||||
# 验证密码
|
||||
if not security.verify_password(password, user["password_hash"]):
|
||||
is_valid, needs_upgrade = security.verify_password_v2(password, user["password_hash"])
|
||||
if not is_valid:
|
||||
await RedisClient.set_login_attempts(username)
|
||||
await LogService.write_login_log(username, 0, ip, user_agent, "用户名或密码错误")
|
||||
return {"success": False, "message": "用户名或密码错误"}
|
||||
|
||||
# 自动升级旧哈希密码
|
||||
if needs_upgrade:
|
||||
try:
|
||||
await UserModel.update_password(user["user_id"], password)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 检查账号状态
|
||||
if user["status"] != 1:
|
||||
await LogService.write_login_log(username, 0, ip, user_agent, "账号已被禁用")
|
||||
@@ -116,8 +124,10 @@ class AuthService:
|
||||
return {"success": False, "message": "用户不存在"}
|
||||
|
||||
# 验证原密码(强制改密时跳过)
|
||||
if not force and not security.verify_password(old_password, user["password_hash"]):
|
||||
return {"success": False, "message": "原密码错误"}
|
||||
if not force:
|
||||
is_valid, _ = security.verify_password_v2(old_password, user["password_hash"])
|
||||
if not is_valid:
|
||||
return {"success": False, "message": "原密码错误"}
|
||||
|
||||
# 验证新密码强度
|
||||
is_valid, msg = security.validate_password_strength(new_password)
|
||||
|
||||
@@ -41,7 +41,8 @@ class ParentService:
|
||||
"student_id": student["student_id"],
|
||||
"student_name": student["name"],
|
||||
"student_no": student["student_no"],
|
||||
"total_points": student["total_points"]
|
||||
"total_points": student["total_points"],
|
||||
"dormitory_number": student.get("dormitory_number")
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user