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:
@@ -530,7 +530,19 @@ func (h *UserHandler) BulkCreateUsers(c *fiber.Ctx) error {
|
|||||||
localUser := h.mapToLocalUser(*identity)
|
localUser := h.mapToLocalUser(*identity)
|
||||||
_ = h.UserRepo.Update(context.Background(), localUser)
|
_ = h.UserRepo.Update(context.Background(), localUser)
|
||||||
if h.KetoOutboxRepo != nil {
|
if h.KetoOutboxRepo != nil {
|
||||||
|
// 1. Sync Role based relationship
|
||||||
h.syncKetoRole(context.Background(), localUser.ID, role, "", "", localUser.TenantID)
|
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,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,17 @@ func (s *orgChartService) ImportCSV(ctx context.Context, tenantID string, r io.R
|
|||||||
Action: domain.KetoOutboxActionCreate,
|
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
|
// Add as owner if applicable
|
||||||
if isOwner {
|
if isOwner {
|
||||||
_ = s.ketoOutboxRepo.Create(ctx, &domain.KetoOutbox{
|
_ = s.ketoOutboxRepo.Create(ctx, &domain.KetoOutbox{
|
||||||
|
|||||||
Reference in New Issue
Block a user