Resolve the caller's org from their JWT. The org_id never comes from the request.
(user: AuthUser)
| 138 | |
| 139 | |
| 140 | async def _require_org(user: AuthUser) -> tuple[str, dict]: |
| 141 | """Resolve the caller's org from their JWT. The org_id never comes from the request.""" |
| 142 | org_id = (user.app_metadata or {}).get("org_id") |
| 143 | if not org_id: |
| 144 | raise HTTPException(status_code=403, detail="You are not a member of an organization.") |
| 145 | |
| 146 | org, _ = await r2_store.get_json(r2_store.org_key(org_id)) |
| 147 | if not org: |
| 148 | logger.error(f"User {user.id} has org_id {org_id} but no org record exists") |
| 149 | raise HTTPException(status_code=404, detail="Organization not found.") |
| 150 | |
| 151 | return org_id, org |
| 152 | |
| 153 | |
| 154 | def _send_invite_email(email: str, org_name: str, token: str) -> None: |
no test coverage detected