fix: unify tenant context keys and load tenant_id from JWT
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"aggios-app/backend/internal/api/middleware"
|
||||
"aggios-app/backend/internal/repository"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -58,14 +59,12 @@ func (h *AgencyHandler) GetProfile(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Get tenant from context (set by middleware)
|
||||
tenantID := r.Context().Value("tenantID")
|
||||
// Get tenant from context (set by auth middleware)
|
||||
tenantID := r.Context().Value(middleware.TenantIDKey)
|
||||
log.Printf("DEBUG GetProfile: tenantID from context = %v (type: %T)", tenantID, tenantID)
|
||||
|
||||
if tenantID == nil {
|
||||
log.Printf("DEBUG GetProfile: tenantID is nil, checking subdomain from context")
|
||||
subdomain := r.Context().Value("subdomain")
|
||||
log.Printf("DEBUG GetProfile: subdomain = %v", subdomain)
|
||||
log.Printf("DEBUG GetProfile: tenantID is nil from auth middleware")
|
||||
http.Error(w, "Tenant not found in context", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
@@ -115,8 +114,8 @@ func (h *AgencyHandler) UpdateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Get tenant from context
|
||||
tenantID := r.Context().Value("tenantID")
|
||||
// Get tenant from context (set by auth middleware)
|
||||
tenantID := r.Context().Value(middleware.TenantIDKey)
|
||||
if tenantID == nil {
|
||||
http.Error(w, "Tenant not found", http.StatusUnauthorized)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user