Реализовать ЛР 7 на оценку 4
Skeleton contracts / contracts (pull_request) Blocked by required conditions
Skeleton contracts / contracts (pull_request) Blocked by required conditions
This commit is contained in:
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, update
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
|
||||
|
||||
@@ -48,6 +48,14 @@ class UserRepository:
|
||||
async with self._sessions() as session:
|
||||
return await session.scalar(select(UserRow).where(UserRow.username == username))
|
||||
|
||||
async def update_password_hash(self, user_id: UUID, old_hash: str, new_hash: str) -> None:
|
||||
async with self._sessions.begin() as session:
|
||||
await session.execute(
|
||||
update(UserRow)
|
||||
.where(UserRow.id == user_id, UserRow.password_hash == old_hash)
|
||||
.values(password_hash=new_hash)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def to_domain(cls, row: UserRow) -> User:
|
||||
return cls._to_domain(row)
|
||||
|
||||
Reference in New Issue
Block a user