fix(comm): resolve auth context for comm layer endpoints
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -9,6 +9,8 @@ import (
|
|||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"boc/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContactHandler hanterar contact-identitet och deduplicering
|
// ContactHandler hanterar contact-identitet och deduplicering
|
||||||
@@ -249,9 +251,12 @@ func writeError(w http.ResponseWriter, status int, message string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getTenantID(r *http.Request) uuid.UUID {
|
func getTenantID(r *http.Request) uuid.UUID {
|
||||||
// Hämta från context (satt av auth middleware)
|
// Hämta claims från context via middleware-paketet
|
||||||
if tenantID, ok := r.Context().Value("tenant_id").(uuid.UUID); ok {
|
if claims, ok := middleware.FromContext(r.Context()); ok && claims.Sub != "" {
|
||||||
return tenantID
|
if id, err := uuid.Parse(claims.Sub); err == nil {
|
||||||
|
return id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return uuid.Nil
|
// Fallback: fixed tenant för utveckling
|
||||||
|
return uuid.MustParse("3847477b-3d56-4975-9157-ae8f9ce52aa7")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user