feat: add organization retrieval endpoint and JWT authentication support
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user