MCPcopy Create free account
hub / github.com/Roy3838/Observer / _require_org

Function _require_org

api/orgs.py:140–151  ·  view source on GitHub ↗

Resolve the caller's org from their JWT. The org_id never comes from the request.

(user: AuthUser)

Source from the content-addressed store, hash-verified

138
139
140async 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
154def _send_invite_email(email: str, org_name: str, token: str) -> None:

Callers 3

get_my_orgFunction · 0.85
invite_memberFunction · 0.85
remove_memberFunction · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected