MCPcopy
hub / github.com/learnhouse/learnhouse / get_user_org_role

Function get_user_org_role

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

Return the user's Role in the org, or None. Does NOT check superadmin.

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

Source from the content-addressed store, hash-verified

55
56
57async def get_user_org_role(user_id: int, org_id: int, db_session: AsyncSession) -> Optional[Role]:
58 """Return the user's Role in the org, or None. Does NOT check superadmin."""
59 user_org = await get_user_org(user_id, org_id, db_session)
60 if not user_org:
61 return None
62 statement = select(Role).where(Role.id == user_org.role_id)
63 return (await db_session.execute(statement)).scalars().first()
64
65
66async def require_org_membership(user_id: int, org_id: int, db_session: AsyncSession) -> None:

Calls 4

get_user_orgFunction · 0.85
firstMethod · 0.45
scalarsMethod · 0.45
executeMethod · 0.45