update main.py
kaasislekker
This commit is contained in:
+28
-2
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user