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

Function _require_org

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

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

Callers 4

get_my_orgFunction · 0.85
get_org_usage_historyFunction · 0.85
invite_memberFunction · 0.85
remove_memberFunction · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected