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

Function _require_org

api/orgs.py:124–135  ·  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

122
123
124async 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
138def _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