forked from mtusi2026/mtusi2026lab2
лаба 2 готова
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from src.core.db.models import User
|
||||
from src.core.db.repo.user import to_user
|
||||
from src.service.dto import UserCredentialsDTO
|
||||
|
||||
|
||||
async def fetch_user_credentials(
|
||||
session: AsyncSession,
|
||||
username: str,
|
||||
) -> UserCredentialsDTO | None:
|
||||
user = await session.scalar(select(User).where(User.username == username))
|
||||
if user is None:
|
||||
return None
|
||||
return UserCredentialsDTO(user=to_user(user), password_hash=user.password_hash)
|
||||
Reference in New Issue
Block a user