Fix organization creation failed

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-03-13 13:47:57 +01:00
parent b87ad9e604
commit 2f229fc27d
2 changed files with 6 additions and 3 deletions

View File

@@ -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)
}

View File

@@ -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