1
0
forked from baron/baron-sso

fix(backend): force keto outbox sync on explicit tenant assignment to self-heal missing relations

This commit is contained in:
2026-03-31 17:51:53 +09:00
parent bc73b85909
commit 6b30580f36

View File

@@ -1282,6 +1282,18 @@ func (h *UserHandler) UpdateUser(c *fiber.Ctx) error {
}
}
}
// [Self-Healing] If the UI explicitly assigned the tenant, force a Keto relation sync.
// This fixes issues where local DB had the tenant, but Keto failed to create the relation previously.
if req.CompanyCode != nil && h.KetoOutboxRepo != nil && updatedLocalUser.TenantID != nil {
_ = h.KetoOutboxRepo.Create(bgCtx, &domain.KetoOutbox{
Namespace: "Tenant",
Object: *updatedLocalUser.TenantID,
Relation: "members",
Subject: "User:" + updatedLocalUser.ID,
Action: domain.KetoOutboxActionCreate,
})
}
}()
}