Skip to content

Commit d3fb463

Browse files
committed
chore: prevent removing members from the default organization
Until multi-organizations is released outside an experiment, the experiment should be backwards compatible.
1 parent a27ac30 commit d3fb463

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

coderd/members.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,19 @@ func (api *API) deleteOrganizationMember(rw http.ResponseWriter, r *http.Request
106106
aReq.Old = member.OrganizationMember.Auditable(member.Username)
107107
defer commitAudit()
108108

109+
if organization.IsDefault {
110+
// Multi-organizations is currently an experiment, which means it is feasible
111+
// for a deployment to enable, then disable this. To maintain backwards
112+
// compatibility, this safety is necessary.
113+
// TODO: Remove this check when multi-organizations is fully supported.
114+
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
115+
Message: "Removing members from the default organization is not supported.",
116+
Detail: "Multi-organizations is currently an experiment, and until it is fully supported, the default org should be protected.",
117+
Validations: nil,
118+
})
119+
return
120+
}
121+
109122
if member.UserID == apiKey.UserID {
110123
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{Message: "cannot remove self from an organization"})
111124
return

0 commit comments

Comments
 (0)