forked from mtusi2026/mtusi2026lab7
wip: apply auth-hardening (interrupted by session end)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+18
-1
@@ -2,7 +2,7 @@ from collections.abc import Iterable
|
||||
from dataclasses import asdict
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, update
|
||||
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@@ -55,6 +55,23 @@ class SqlAlchemyUserRepository(AbstractUserRepository):
|
||||
password_hash=password_hash,
|
||||
)
|
||||
|
||||
async def update_password_hash(
|
||||
self,
|
||||
*,
|
||||
user_id: UUID,
|
||||
old_hash: str,
|
||||
new_hash: str,
|
||||
) -> bool:
|
||||
"""Условный UPDATE: безусловный затёр бы новый хэш параллельного
|
||||
входа старым пересчётом."""
|
||||
statement = (
|
||||
update(User)
|
||||
.where(User.id == user_id, User.password_hash == old_hash)
|
||||
.values(password_hash=new_hash)
|
||||
.returning(User.id)
|
||||
)
|
||||
return (await self._session.execute(statement)).first() is not None
|
||||
|
||||
async def get_existing_user_ids(
|
||||
self,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user