1
0
forked from baron/baron-sso

fix: resolve build errors and fix member count synchronization issues in bulk/org-chart import

This commit is contained in:
2026-03-04 17:42:58 +09:00
parent 16ba7ee47a
commit 03e8ed4822
2 changed files with 23 additions and 0 deletions

View File

@@ -530,7 +530,19 @@ func (h *UserHandler) BulkCreateUsers(c *fiber.Ctx) error {
localUser := h.mapToLocalUser(*identity)
_ = h.UserRepo.Update(context.Background(), localUser)
if h.KetoOutboxRepo != nil {
// 1. Sync Role based relationship
h.syncKetoRole(context.Background(), localUser.ID, role, "", "", localUser.TenantID)
// 2. Sync direct membership to the Tenant (for count)
if localUser.TenantID != nil && *localUser.TenantID != "" {
_ = h.KetoOutboxRepo.Create(context.Background(), &domain.KetoOutbox{
Namespace: "Tenant",
Object: *localUser.TenantID,
Relation: "members",
Subject: "User:" + localUser.ID,
Action: domain.KetoOutboxActionCreate,
})
}
}
}
}

View File

@@ -139,6 +139,17 @@ func (s *orgChartService) ImportCSV(ctx context.Context, tenantID string, r io.R
Action: domain.KetoOutboxActionCreate,
})
// [New] Also add as member of the root Tenant (for tenant-level member count)
if leafID != tenantID {
_ = s.ketoOutboxRepo.Create(ctx, &domain.KetoOutbox{
Namespace: "Tenant",
Object: tenantID,
Relation: "members",
Subject: "User:" + kratosID,
Action: domain.KetoOutboxActionCreate,
})
}
// Add as owner if applicable
if isOwner {
_ = s.ketoOutboxRepo.Create(ctx, &domain.KetoOutbox{