Resolve the caller's org from their JWT. The org_id never comes from the request.
(user: AuthUser)
| 122 | |
| 123 | |
| 124 | async def _require_org(user: AuthUser) -> tuple[str, dict]: |
| 125 | """Resolve the caller's org from their JWT. The org_id never comes from the request.""" |
| 126 | org_id = (user.app_metadata or {}).get("org_id") |
| 127 | if not org_id: |
| 128 | raise HTTPException(status_code=403, detail="You are not a member of an organization.") |
| 129 | |
| 130 | org, _ = await r2_store.get_json(r2_store.org_key(org_id)) |
| 131 | if not org: |
| 132 | logger.error(f"User {user.id} has org_id {org_id} but no org record exists") |
| 133 | raise HTTPException(status_code=404, detail="Organization not found.") |
| 134 | |
| 135 | return org_id, org |
| 136 | |
| 137 | |
| 138 | def _send_invite_email(email: str, org_name: str, token: str) -> None: |
no test coverage detected