Plug trust center part 1

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-01-09 19:14:17 +01:00
committed by Bryan Frimin
parent 663400c4f6
commit 7322201dab
41 changed files with 1959 additions and 1033 deletions

View File

@@ -15,7 +15,6 @@
package server
import (
"context"
"errors"
"net/http"
"strings"
@@ -193,7 +192,7 @@ func (s *Server) loadTrustCenterBySlugOrID(next http.Handler) http.Handler {
)
}
ctx = s.addTrustCenterToContext(ctx, trustCenter.ID.TenantID(), trustCenter.OrganizationID)
ctx = trust_v1.ContextWithTrustCenter(ctx, *trustCenter)
next.ServeHTTP(w, r.WithContext(ctx))
})
}
@@ -235,16 +234,20 @@ func (s *Server) loadTrustCenterByDomain(next http.Handler) http.Handler {
log.String("organization_id", organizationID.String()),
)
ctx = s.addTrustCenterToContext(ctx, organizationID.TenantID(), organizationID)
trustCenter, err := s.proboService.LoadTrustCenterByOrganizationID(ctx, organizationID)
if err != nil {
s.logger.WarnCtx(ctx, "trust center not found",
log.Error(err),
)
http.Error(w, "Trust center not found", http.StatusNotFound)
return
}
ctx = trust_v1.ContextWithTrustCenter(ctx, *trustCenter)
next.ServeHTTP(w, r.WithContext(ctx))
})
}
func (s *Server) addTrustCenterToContext(ctx context.Context, tenantID, organizationID interface{}) context.Context {
ctx = context.WithValue(ctx, trust_v1.CustomDomainOrganizationIDKey, organizationID)
return ctx
}
func (s *Server) stripTrustPrefix(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
slugOrId := chi.URLParam(r, "slugOrId")