This commit is contained in:
2026-01-25 16:20:59 +01:00
parent 71f8d4cd51
commit 76834b0e10
2 changed files with 13 additions and 0 deletions

View File

@@ -44,22 +44,30 @@ async def update_user(user_id: int, user_update: schemas.UserUpdate, background_
if not db_user:
raise HTTPException(status_code=404, detail="User not found")
print(f"DEBUG UPDATE: Updating user {user_id} with data: {user_update}")
if user_update.password:
print("DEBUG UPDATE: Updating password")
db_user.hashed_password = auth_utils.get_password_hash(user_update.password)
# Send email on password change
background_tasks.add_task(email.send_welcome_email, db_user.email, db_user.username, user_update.password)
if user_update.email:
print(f"DEBUG UPDATE: Updating email to {user_update.email}")
db_user.email = user_update.email
if user_update.username:
print(f"DEBUG UPDATE: Updating username to {user_update.username}")
db_user.username = user_update.username
if user_update.is_active is not None:
print(f"DEBUG UPDATE: Updating is_active to {user_update.is_active}")
db_user.is_active = user_update.is_active
if user_update.is_admin is not None:
print(f"DEBUG UPDATE: Updating is_admin to {user_update.is_admin}")
db_user.is_admin = user_update.is_admin
db.commit()
db.refresh(db_user)
print(f"DEBUG UPDATE: User after update: id={db_user.id}, username={db_user.username}, email={db_user.email}, is_admin={db_user.is_admin}")
return db_user
@router.post("/{user_id}/assign/{app_id}")