fix(auth): avoid redundant password hashing in registration races

This commit is contained in:
2026-11-15 21:59:08 +03:00
parent 869cff59d9
commit 78670b9fa6
5 changed files with 43 additions and 8 deletions
+9
View File
@@ -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
):