idk i think it works

This commit is contained in:
2026-01-20 17:13:41 +00:00
parent 5d39a150e7
commit c0a1a0b944
2 changed files with 24 additions and 2 deletions

View File

@@ -57,6 +57,8 @@ async def edit_user(user_id: int, updates: dict):
"""Edits an existing user."""
if db.mode == "mysql":
placeholders = ", ".join(["%s"] * len(updates))
if updates.get("password") is not None: # there is a password update
updates["password"] = bcrypt.hashpw(updates["password"].encode(), bcrypt.gensalt()).decode()
values = list(updates.values())
query = f"UPDATE users SET {', '.join([f'{key} = %s' for key in updates.keys()])} WHERE id = %s"
values.append(user_id)