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

Function remove_member

api/orgs.py:783–808  ·  view source on GitHub ↗
(current_user: AuthUser, body: RemoveRequest)

Source from the content-addressed store, hash-verified

781
782@orgs_router.delete("/orgs/members", summary="Remove someone from the org (owner only)")
783async def remove_member(current_user: AuthUser, body: RemoveRequest):
784 org_id, org = await _require_org(current_user)
785 email = body.email.lower()
786
787 # Removal is the one destructive action, so it is restricted to the billing
788 # contact. This is why there is an owner_email field and not a role model.
789 if not current_user.email or current_user.email.lower() != org["owner_email"]:
790 raise HTTPException(status_code=403, detail="Only the organization owner can remove members.")
791 if email == org["owner_email"]:
792 raise HTTPException(status_code=400, detail="The owner cannot be removed. Contact Observer to change the billing contact.")
793
794 member = _find_member(org, email)
795 if not member or member["status"] == "removed":
796 raise HTTPException(status_code=404, detail=f"{email} is not on this team.")
797
798 await _revoke_seat(email, member.get("auth0_user_id"))
799
800 def revoke(rec):
801 m = _find_member(rec, email)
802 if m:
803 m["status"] = "removed"
804 m["removed_at"] = _now_iso()
805 await r2_store.update_json(r2_store.org_key(org_id), revoke)
806
807 logger.info(f"{current_user.email} removed {email} from {org_id}")
808 return {"email": email, "status": "removed"}
809
810
811# --- Stripe sync ------------------------------------------------------------

Callers

nothing calls this directly

Calls 4

_require_orgFunction · 0.85
_find_memberFunction · 0.85
_revoke_seatFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected