From 951adbc600923d6af641737b86003bbfccdf8ed7 Mon Sep 17 00:00:00 2001 From: Sacha Al Himdani Date: Fri, 10 Oct 2025 17:44:31 +0200 Subject: [PATCH] Use custom domain in trust center invitation Signed-off-by: Sacha Al Himdani --- pkg/probo/trust_center_access_service.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pkg/probo/trust_center_access_service.go b/pkg/probo/trust_center_access_service.go index c47819f24..a1e705577 100644 --- a/pkg/probo/trust_center_access_service.go +++ b/pkg/probo/trust_center_access_service.go @@ -386,10 +386,27 @@ func (s TrustCenterAccessService) sendAccessEmail(ctx context.Context, tx pg.Con return fmt.Errorf("cannot load organization: %w", err) } + hostname := s.svc.hostname + path := "/trust/" + trustCenter.Slug + "/access" + + if organization.CustomDomainID != nil { + customDomain, err := s.svc.CustomDomains.GetOrganizationCustomDomain(ctx, organization.ID) + if err != nil { + return fmt.Errorf("cannot load custom domain: %w", err) + } + + if customDomain == nil || customDomain.SSLStatus != coredata.CustomDomainSSLStatusActive { + return fmt.Errorf("custom domain is not active") + } + + hostname = customDomain.Domain + path = "/access" + } + accessURL := url.URL{ Scheme: "https", - Host: s.svc.hostname, - Path: "/trust/" + trustCenter.Slug + "/access", + Host: hostname, + Path: path, RawQuery: url.Values{ "token": []string{accessToken}, }.Encode(),