forked from baron/baron-sso
ef286330a2 반영 code-check 오류 수정
This commit is contained in:
@@ -911,6 +911,8 @@ export_with_ids = ""
|
||||
export_without_ids = ""
|
||||
import = ""
|
||||
title = ""
|
||||
view.hierarchy = ""
|
||||
view.list = ""
|
||||
view_org_chart = ""
|
||||
|
||||
[ui.admin.tenants.domain_conflict]
|
||||
|
||||
@@ -2,9 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
"log"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1587,6 +1587,10 @@ seed_badge = "초기 설정"
|
||||
title = "테넌트 목록"
|
||||
view_org_chart = "전체 조직도 보기"
|
||||
|
||||
[ui.admin.tenants.view]
|
||||
hierarchy = "계층 구조"
|
||||
list = "평면 목록"
|
||||
|
||||
[ui.admin.tenants.admins]
|
||||
add_button = "관리자 추가"
|
||||
already_admin = "이미 관리자"
|
||||
|
||||
@@ -1456,6 +1456,10 @@ seed_badge = ""
|
||||
title = ""
|
||||
view_org_chart = ""
|
||||
|
||||
[ui.admin.tenants.view]
|
||||
hierarchy = ""
|
||||
list = ""
|
||||
|
||||
[ui.admin.tenants.admins]
|
||||
add_button = ""
|
||||
already_admin = ""
|
||||
|
||||
Reference in New Issue
Block a user