forked from mtusi2026/mtusi2026lab4
fix(auth): avoid redundant password hashing in registration races
This commit is contained in:
@@ -92,6 +92,15 @@ class PostgresRepository:
|
||||
return None, None
|
||||
return user_dto(row), row["password_hash"]
|
||||
|
||||
def username_exists(self, *, username: str) -> bool:
|
||||
with self.database.connection() as conn:
|
||||
return (
|
||||
conn.execute(
|
||||
"SELECT 1 FROM users WHERE username=%s", (username,)
|
||||
).fetchone()
|
||||
is not None
|
||||
)
|
||||
|
||||
def add_session(
|
||||
self, *, digest: bytes, user_id: UUID, created_at, expires_at
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user