feat: add organization retrieval endpoint and JWT authentication support

This commit is contained in:
Artem Kashaev
2025-11-27 15:04:31 +05:00
parent 845737abca
commit ea8f0eda65
3 changed files with 51 additions and 11 deletions
+15 -9
View File
@@ -1,16 +1,22 @@
"""Organization-related API stubs."""
"""Organization-related API endpoints."""
from __future__ import annotations
from fastapi import APIRouter, status
from fastapi import APIRouter, Depends
from app.api.deps import get_current_user, get_organization_repository
from app.models.organization import OrganizationRead
from app.models.user import User
from app.repositories.org_repo import OrganizationRepository
router = APIRouter(prefix="/organizations", tags=["organizations"])
def _stub(endpoint: str) -> dict[str, str]:
return {"detail": f"{endpoint} is not implemented yet"}
@router.get("/me", response_model=list[OrganizationRead])
async def list_user_organizations(
current_user: User = Depends(get_current_user),
repo: OrganizationRepository = Depends(get_organization_repository),
) -> list[OrganizationRead]:
"""Return organizations the authenticated user belongs to."""
@router.get("/me", status_code=status.HTTP_501_NOT_IMPLEMENTED)
async def list_user_organizations() -> dict[str, str]:
"""Placeholder for returning organizations linked to the current user."""
return _stub("GET /organizations/me")
organizations = await repo.list_for_user(current_user.id)
return [OrganizationRead.model_validate(org) for org in organizations]