Initial LinkLog implementation
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
from datetime import datetime, timezone
|
||||
from hashlib import sha256
|
||||
|
||||
from backend.app.database import get_connection
|
||||
|
||||
|
||||
def hash_password(password: str) -> str:
|
||||
return sha256(password.encode('utf-8')).hexdigest()
|
||||
|
||||
|
||||
def authenticate_user(username: str, password: str):
|
||||
password_hash = hash_password(password)
|
||||
with get_connection() as conn:
|
||||
row = conn.execute(
|
||||
'SELECT * FROM users WHERE username = ? AND password_hash = ?',
|
||||
(username, password_hash),
|
||||
).fetchone()
|
||||
return dict(row) if row else None
|
||||
Reference in New Issue
Block a user