This commit is contained in:
2026-09-16 17:55:04 +08:00
parent 3f120417d1
commit 4537faf2c4
39 changed files with 986 additions and 423 deletions
+10 -2
View File
@@ -212,10 +212,15 @@ async def create_user(
if existing_email.scalar_one_or_none():
raise HTTPException(status_code=400, detail="邮箱已存在")
try:
hashed_password = get_password_hash(user_data.password)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
user = User(
username=user_data.username,
email=user_data.email,
hashed_password=get_password_hash(user_data.password),
hashed_password=hashed_password,
full_name=user_data.full_name,
is_active=True
)
@@ -313,7 +318,10 @@ async def reset_user_password(
if not user:
raise HTTPException(status_code=404, detail="用户不存在")
user.hashed_password = get_password_hash(new_password)
try:
user.hashed_password = get_password_hash(new_password)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
await db_session.commit()
logger.info(f"管理员 {current_user.username} 重置了用户 {user.username} 的密码")