fix: 修复修改密码接口数据库不更新问题

This commit is contained in:
菜鸟生产 2026-03-18 13:35:51 +08:00
parent 514b592983
commit b490043f2e
2 changed files with 8 additions and 3 deletions

View File

@ -106,15 +106,20 @@ def change_password(
"""修改当前用户密码"""
from app.core.auth import verify_password, get_password_hash
# 在当前session中重新查询用户
user = db.query(User).filter(User.f99_90_id == current_user.f99_90_id).first()
if not user:
raise HTTPException(status_code=404, detail="用户不存在")
# 验证旧密码
if not verify_password(old_password, current_user.password):
if not verify_password(old_password, user.password):
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="当前密码错误"
)
# 更新密码
current_user.password = get_password_hash(new_password)
user.password = get_password_hash(new_password)
db.commit()
return {"message": "密码修改成功"}

View File

@ -2,7 +2,7 @@
# Version Configuration for Zodiac Collection Management System
# 当前版本号 (语义化版本:主版本。次版本.修订版)
VERSION=1.1.2
VERSION=1.1.3
# 版本代号 (可选)
VERSION_CODENAME="新生"