async def get_user_from_api_key(db: AsyncSession, api_key: str) -> schemas.User:
    """Retrieve user from database using the API key.

    First validate the API key and then retrieve the user from the database.

    Args:
    ----
        db (AsyncSession): Database session.
        api_key (str): The plain API key to validate.

    Returns:
    -------
        schemas.User: User details from the database.

    Raises:
    ------
        HTTPException: If the user is not found or the API key is invalid.
    """
    try:
        # This function now handles decryption internally
        api_key_obj = await crud.api_key.get_by_key(db, key=api_key)
    except ValueError as e:
        logger.error(f"Error retrieving API key: {e}", exc_info=True)
        if "expired" in str(e):
            raise HTTPException(status_code=403, detail="API key has expired") from e
        raise HTTPException(status_code=403, detail="Invalid API key") from e
    except NotFoundException as e:
        logger.error(f"API key not found: {e}", exc_info=True)
        raise HTTPException(status_code=403, detail="API key not found") from e

    # Use the existing relationship
    user = api_key_obj.created_by
    return schemas.User.model_validate(user)
Retrieve user from database using the API key.

    First validate the API key and then retrieve the user from the database.

    Args:
    ----
        db (AsyncSession): Database session.
        api_key (str): The plain API key to validate.

    Returns:
    -------
        schemas.User: User details from the database.

    Raises:
    ------
        HTTPException: If the user is not found or the API key is invalid.
    
backend/airweave/api/deps.py