tmp: debug login to diagnose 401

This commit is contained in:
Vadym Samoilenko 2026-03-26 13:18:17 +00:00
parent db4a431910
commit 9d292f80da

View file

@ -20,6 +20,12 @@ router = APIRouter(prefix="/api/auth", tags=["auth"])
async def login(body: LoginRequest, db: AsyncSession = Depends(get_db)):
result = await db.execute(select(User).where(User.email == body.email))
user = result.scalar_one_or_none()
import logging
log = logging.getLogger("auth.login")
log.warning("LOGIN email=%r found=%s pw_len=%d pw_bytes=%s match=%s",
body.email, user is not None, len(body.password),
body.password.encode().hex(),
verify_password(body.password, user.password_hash) if user else "no_user")
if not user or not user.is_active or not verify_password(body.password, user.password_hash):
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid credentials")
return TokenResponse(