From 2f229fc27dd5932b5cb0e692f9034b949d1fc26a Mon Sep 17 00:00:00 2001 From: gearnode Date: Thu, 13 Mar 2025 13:47:57 +0100 Subject: [PATCH] Fix organization creation failed Signed-off-by: gearnode --- pkg/server/api/console/v1/resolver.go | 6 +++--- pkg/server/api/console/v1/v1_resolver.go | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/server/api/console/v1/resolver.go b/pkg/server/api/console/v1/resolver.go index 12f56d7f9..2fadb8f36 100644 --- a/pkg/server/api/console/v1/resolver.go +++ b/pkg/server/api/console/v1/resolver.go @@ -185,7 +185,7 @@ func graphqlHandler(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg ctx = context.WithValue(ctx, sessionContextKey, session) ctx = context.WithValue(ctx, userContextKey, user) - ctx = context.WithValue(ctx, userTenantContextKey, tenantIDs) + ctx = context.WithValue(ctx, userTenantContextKey, &tenantIDs) srv.ServeHTTP(w, r.WithContext(ctx)) @@ -197,9 +197,9 @@ func graphqlHandler(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg } func (r *Resolver) GetTenantServiceIfAuthorized(ctx context.Context, tenantID gid.TenantID) *probo.TenantService { - tenantIDs, _ := ctx.Value(userTenantContextKey).([]gid.TenantID) + tenantIDs, _ := ctx.Value(userTenantContextKey).(*[]gid.TenantID) - for _, id := range tenantIDs { + for _, id := range *tenantIDs { if id == tenantID { return r.proboSvc.WithTenant(tenantID) } diff --git a/pkg/server/api/console/v1/v1_resolver.go b/pkg/server/api/console/v1/v1_resolver.go index 72014a1d1..721765a72 100644 --- a/pkg/server/api/console/v1/v1_resolver.go +++ b/pkg/server/api/console/v1/v1_resolver.go @@ -192,6 +192,9 @@ func (r *mutationResolver) CreateOrganization(ctx context.Context, input types.C return nil, fmt.Errorf("cannot add user to organization: %w", err) } + tenantIDs, _ := ctx.Value(userTenantContextKey).(*[]gid.TenantID) + *tenantIDs = append(*tenantIDs, organization.ID.TenantID()) + return &types.CreateOrganizationPayload{ OrganizationEdge: types.NewOrganizationEdge(organization), }, nil