feat(webui): act in a selected organisation the caller is a member of, enforced at the dashboard and the State Store

This commit is contained in:
sam committed 2026-10-27 11:06:18 +11:00
1 parent 2cf9d435cc
commit 2fb0084d2c
17 files changed
+356 -69

No files matched your search

+9 -4
View File
@@ -33,7 +33,8 @@ func (s *Server) orgInPath(w http.ResponseWriter, r *http.Request) (org.OrgID, b
}
// handleOrgsList lists every org to an instance admin and the caller's own
// to anyone else, naming the caller's org and whether it may switch.
// and member orgs to anyone else, naming the org the caller acts in and the
// ones it may select.
func (s *Server) handleOrgsList(w http.ResponseWriter, r *http.Request) {
if !s.orgReady(w) {
return
@@ -44,13 +45,17 @@ func (s *Server) handleOrgsList(w http.ResponseWriter, r *http.Request) {
return
}
caller, admin := policyOrg(r), instanceOwner(r)
out := []org.Org{}
principal, _ := access.PrincipalFromContext(r.Context())
out, member := []org.Org{}, []org.OrgID{}
for _, value := range values {
if value.ID == caller || admin {
if value.ID == caller || admin || principal.Member(value.ID) {
out = append(out, value)
}
if value.ID == caller || principal.Member(value.ID) {
member = append(member, value.ID)
}
}
writeJSON(w, map[string]any{"orgs": out, "current": caller, "instance_admin": admin})
writeJSON(w, map[string]any{"orgs": out, "current": caller, "instance_admin": admin, "member_orgs": member})
}
// handleOrgCreate creates an org with its default workspace and first owner.