From 8307f65f6a797cfb4e9876a74b53457b1140ae26 Mon Sep 17 00:00:00 2001 From: kyy Date: Fri, 8 May 2026 15:23:15 +0900 Subject: [PATCH] =?UTF-8?q?ef286330a2=20=EB=B0=98=EC=98=81=20code-check=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adminfront/src/locales/template.toml | 2 + backend/check_aaa2.go | 3 +- backend/internal/handler/user_handler.go | 91 ++++++++++++------------ locales/en.toml | 4 ++ locales/ko.toml | 4 ++ locales/template.toml | 4 ++ 6 files changed, 62 insertions(+), 46 deletions(-) diff --git a/adminfront/src/locales/template.toml b/adminfront/src/locales/template.toml index d2b06aea..f02882e6 100644 --- a/adminfront/src/locales/template.toml +++ b/adminfront/src/locales/template.toml @@ -911,6 +911,8 @@ export_with_ids = "" export_without_ids = "" import = "" title = "" +view.hierarchy = "" +view.list = "" view_org_chart = "" [ui.admin.tenants.domain_conflict] diff --git a/backend/check_aaa2.go b/backend/check_aaa2.go index 29a5df6c..55fe2c0c 100644 --- a/backend/check_aaa2.go +++ b/backend/check_aaa2.go @@ -2,9 +2,10 @@ package main import ( "fmt" + "log" + "gorm.io/driver/postgres" "gorm.io/gorm" - "log" ) type User struct { diff --git a/backend/internal/handler/user_handler.go b/backend/internal/handler/user_handler.go index 8e841a6d..d921c33e 100644 --- a/backend/internal/handler/user_handler.go +++ b/backend/internal/handler/user_handler.go @@ -1620,54 +1620,55 @@ func (h *UserHandler) UpdateUser(c *fiber.Ctx) error { } } } else { - // Normal update (Move): replace primary company code and remove the old one from existingCodes - currentPrimary := extractTraitString(traits, "companyCode") - if currentPrimary != "" && currentPrimary != code { - // Remove old primary from existingCodes - var newCodes []string - for _, existing := range existingCodes { - if existing != currentPrimary { - newCodes = append(newCodes, existing) - } - } - existingCodes = newCodes + // Normal update (Move): replace primary company code and remove the old one from existingCodes + currentPrimary := extractTraitString(traits, "companyCode") + if currentPrimary != "" && currentPrimary != code { + // Remove old primary from existingCodes + var newCodes []string + for _, existing := range existingCodes { + if existing != currentPrimary { + newCodes = append(newCodes, existing) + } + } + existingCodes = newCodes - // [Keto Sync] Remove membership for the old tenant - if h.TenantService != nil && h.KetoOutboxRepo != nil { - go func(removedSlug string) { - bgCtx := context.Background() - if t, err := h.TenantService.GetTenantBySlug(bgCtx, removedSlug); err == nil && t != nil { - _ = h.KetoOutboxRepo.Create(bgCtx, &domain.KetoOutbox{ - Namespace: "Tenant", - Object: t.ID, - Relation: "members", - Subject: "User:" + userID, - Action: domain.KetoOutboxActionDelete, - }) - } - }(currentPrimary) - } - } + // [Keto Sync] Remove membership for the old tenant + if h.TenantService != nil && h.KetoOutboxRepo != nil { + go func(removedSlug string) { + bgCtx := context.Background() + if t, err := h.TenantService.GetTenantBySlug(bgCtx, removedSlug); err == nil && t != nil { + _ = h.KetoOutboxRepo.Create(bgCtx, &domain.KetoOutbox{ + Namespace: "Tenant", + Object: t.ID, + Relation: "members", + Subject: "User:" + userID, + Action: domain.KetoOutboxActionDelete, + }) + } + }(currentPrimary) + } + } - traits["companyCode"] = code - // Resolve TenantID for Kratos Trait - if h.TenantService != nil && code != "" { - if tenant, err := h.TenantService.GetTenantBySlug(c.Context(), code); err == nil && tenant != nil { - traits["tenant_id"] = tenant.ID - } - } + traits["companyCode"] = code + // Resolve TenantID for Kratos Trait + if h.TenantService != nil && code != "" { + if tenant, err := h.TenantService.GetTenantBySlug(c.Context(), code); err == nil && tenant != nil { + traits["tenant_id"] = tenant.ID + } + } - found := false - for _, existing := range existingCodes { - if existing == code { - found = true - break - } - } - if !found && code != "" { - existingCodes = append(existingCodes, code) - } - } } + found := false + for _, existing := range existingCodes { + if existing == code { + found = true + break + } + } + if !found && code != "" { + existingCodes = append(existingCodes, code) + } + } + } // Deduplicate and save back companyCodes var codesToSave []string diff --git a/locales/en.toml b/locales/en.toml index 785df7d0..10e89f32 100644 --- a/locales/en.toml +++ b/locales/en.toml @@ -1112,6 +1112,10 @@ seed_badge = "Seed" title = "Tenant Registry" view_org_chart = "View Full Org Chart" +[ui.admin.tenants.view] +hierarchy = "Hierarchy" +list = "List" + [ui.admin.tenants.domain_conflict] description = "" title = "Domain conflict" diff --git a/locales/ko.toml b/locales/ko.toml index 466eebcf..8a9f1f15 100644 --- a/locales/ko.toml +++ b/locales/ko.toml @@ -1587,6 +1587,10 @@ seed_badge = "초기 설정" title = "테넌트 목록" view_org_chart = "전체 조직도 보기" +[ui.admin.tenants.view] +hierarchy = "계층 구조" +list = "평면 목록" + [ui.admin.tenants.admins] add_button = "관리자 추가" already_admin = "이미 관리자" diff --git a/locales/template.toml b/locales/template.toml index 5627cf0d..5c5df6b4 100644 --- a/locales/template.toml +++ b/locales/template.toml @@ -1456,6 +1456,10 @@ seed_badge = "" title = "" view_org_chart = "" +[ui.admin.tenants.view] +hierarchy = "" +list = "" + [ui.admin.tenants.admins] add_button = "" already_admin = ""