# app/api/v1/endpoints/users.py import logging from fastapi import APIRouter, Depends, HTTPException from app.api.dependencies import get_current_user # Import the dependency from app.schemas.user import UserPublic # Import the response schema from app.models import User as UserModel # Import the DB model for type hinting logger = logging.getLogger(__name__) router = APIRouter() @router.get( "/me", response_model=UserPublic, # Use the public schema to avoid exposing hash summary="Get Current User", description="Retrieves the details of the currently authenticated user.", tags=["Users"] ) async def read_users_me( current_user: UserModel = Depends(get_current_user) # Apply the dependency ): """ Returns the data for the user associated with the current valid access token. """ logger.info(f"Fetching details for current user: {current_user.email}") # The 'current_user' object is the SQLAlchemy model instance returned by the dependency. # Pydantic's response_model will automatically convert it using UserPublic schema. return current_user # Add other user-related endpoints here later (e.g., update user, list users (admin))