fix: 修复修改密码接口数据库不更新问题
This commit is contained in:
parent
514b592983
commit
b490043f2e
|
|
@ -106,15 +106,20 @@ def change_password(
|
||||||
"""修改当前用户密码"""
|
"""修改当前用户密码"""
|
||||||
from app.core.auth import verify_password, get_password_hash
|
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(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
detail="当前密码错误"
|
detail="当前密码错误"
|
||||||
)
|
)
|
||||||
|
|
||||||
# 更新密码
|
# 更新密码
|
||||||
current_user.password = get_password_hash(new_password)
|
user.password = get_password_hash(new_password)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
return {"message": "密码修改成功"}
|
return {"message": "密码修改成功"}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# Version Configuration for Zodiac Collection Management System
|
# Version Configuration for Zodiac Collection Management System
|
||||||
|
|
||||||
# 当前版本号 (语义化版本:主版本。次版本.修订版)
|
# 当前版本号 (语义化版本:主版本。次版本.修订版)
|
||||||
VERSION=1.1.2
|
VERSION=1.1.3
|
||||||
|
|
||||||
# 版本代号 (可选)
|
# 版本代号 (可选)
|
||||||
VERSION_CODENAME="新生"
|
VERSION_CODENAME="新生"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue