major fixes

This commit is contained in:
2026-08-22 18:51:17 +02:00
parent 0ff24b1534
commit 0c154254c3
36 changed files with 2212 additions and 42 deletions
@@ -11,7 +11,7 @@ import (
"github.com/google/uuid"
)
// GET /api/billing/capabilities — effective plan ∩ global features for the active company.
// GET /api/billing/capabilities — effective plan ∩ global ∩ member features for the caller.
func (s *Server) handleGetCapabilities(w http.ResponseWriter, r *http.Request) {
if s.Billing == nil {
Error(w, http.StatusServiceUnavailable, "billing unavailable")
@@ -22,7 +22,10 @@ func (s *Server) handleGetCapabilities(w http.ResponseWriter, r *http.Request) {
Error(w, http.StatusUnauthorized, "company required")
return
}
caps, err := s.Billing.CapabilitiesForCompany(r.Context(), cid)
// Member-aware: the company owner's per-member overlay narrows what this caller
// sees, so nav / route guard / feature gates all hide the same surfaces at once.
uid, _ := UserIDFromContext(r.Context())
caps, err := s.Billing.CapabilitiesForMember(r.Context(), cid, uid)
if err != nil {
Error(w, http.StatusInternalServerError, "failed to load capabilities")
return