19 lines
689 B
Python
19 lines
689 B
Python
from fastapi import Depends, HTTPException, status
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.database import get_postgres_session
|
|
from app.models import Account
|
|
from app.routers.auth import get_current_account
|
|
from app.services.org_members import can_manage_org_members
|
|
|
|
|
|
async def require_org_manager(
|
|
account: Account = Depends(get_current_account),
|
|
session: AsyncSession = Depends(get_postgres_session),
|
|
) -> Account:
|
|
if not await can_manage_org_members(session, account):
|
|
raise HTTPException(
|
|
status_code=status.HTTP_403_FORBIDDEN,
|
|
detail="Only company admins can manage organization settings.",
|
|
)
|
|
return account
|