ui enhancement company

This commit is contained in:
debu-2 2026-10-04 20:32:18 +05:30
parent cc3f3f3de5
commit c01914736b
14 changed files with 876 additions and 159 deletions

View file

@ -0,0 +1,24 @@
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.domain_provisioning import account_is_domain_owner
async def require_domain_owner(
account: Account = Depends(get_current_account),
session: AsyncSession = Depends(get_postgres_session),
) -> Account:
if account.account_type != "company" or not account.company_domain:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Company accounts only.",
)
if not await account_is_domain_owner(session, account.id, account.company_domain):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Only the domain owner can manage administrators.",
)
return account