update main.py

kaasislekker
This commit is contained in:
ben
2026-08-18 15:21:35 +02:00
parent 0cec991cbc
commit d2a6e14c5f
+28 -2
View File
@@ -153,7 +153,31 @@ def change_password(user_id: int, old_password: str, new_password: str):
"status": "updated",
}
def delete_me(user_id):
def delete_me(user_id, password):
user = fetch_one(
"""
SELECT password_hash
FROM users
WHERE id = ?
""",
(user_id,)
)
if user is None:
return {
"status": "failed",
"reason": "user_not_found",
}
if not bcrypt.checkpw(
password.encode(),
user["password_hash"].encode(),
):
return {
"status": "failed",
"reason": "incorrect_password",
}
owned_rooms = fetch_all(
"""
SELECT id
@@ -208,4 +232,6 @@ def delete_me(user_id):
(user_id,)
)
return {"status": "deleted"}
return {
"status": "deleted"
}