(current_user: AuthUser, body: RemoveRequest)
| 781 | |
| 782 | @orgs_router.delete("/orgs/members", summary="Remove someone from the org (owner only)") |
| 783 | async 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 ------------------------------------------------------------ |
nothing calls this directly
no test coverage detected