MCPcopy
hub / github.com/learnhouse/learnhouse / is_org_admin

Function is_org_admin

apps/api/src/security/org_auth.py:48–54  ·  view source on GitHub ↗

Check if user is an admin/maintainer of the org (or a superadmin).

(user_id: int, org_id: int, db_session: AsyncSession)

Source from the content-addressed store, hash-verified

46
47
48async def is_org_admin(user_id: int, org_id: int, db_session: AsyncSession) -> bool:
49 """Check if user is an admin/maintainer of the org (or a superadmin)."""
50 if await is_user_superadmin(user_id, db_session):
51 logger.debug("Superadmin bypass: user %s accessed org %s", user_id, org_id)
52 return True
53 user_org = await get_user_org(user_id, org_id, db_session)
54 return user_org is not None and user_org.role_id in ADMIN_OR_MAINTAINER_ROLE_IDS
55
56
57async def get_user_org_role(user_id: int, org_id: int, db_session: AsyncSession) -> Optional[Role]:

Calls 2

is_user_superadminFunction · 0.90
get_user_orgFunction · 0.85