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)