Check if user is an admin/maintainer of the org (or a superadmin).
(user_id: int, org_id: int, db_session: AsyncSession)
| 46 | |
| 47 | |
| 48 | async 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 | |
| 57 | async def get_user_org_role(user_id: int, org_id: int, db_session: AsyncSession) -> Optional[Role]: |