login endpont

This commit is contained in:
ben
2026-08-03 12:30:33 +02:00
parent 3d1d4bcd5d
commit 42b2177a13
3 changed files with 29 additions and 2 deletions
+20 -1
View File
@@ -16,4 +16,23 @@ def create_user(username, password):
(username, password_hash)
)
return user_id
return user_id
def verify_user(username, password):
from database import fetch_one
user = fetch_one(
"SELECT * FROM users WHERE username = ?",
(username,)
)
if not user:
return None
if bcrypt.checkpw(
password.encode(),
user["password_hash"].encode()
):
return user["id"]
return None