1
0
forked from baron/baron-sso

fix: UpdateMe 핸들러 내 계층형 메타데이터 처리 및 로그인 ID 동기화 로직 보강

This commit is contained in:
2026-03-25 17:14:40 +09:00
parent b3f0548c10
commit 5d81027b34

View File

@@ -5283,20 +5283,27 @@ func (h *AuthHandler) UpdateMe(c *fiber.Ctx) error {
if schemaCompCode != "" && h.TenantService != nil {
if tenant, err := h.TenantService.GetTenantBySlug(c.Context(), schemaCompCode); err == nil && tenant != nil {
if loginIDField, ok := tenant.Config["loginIdField"].(string); ok && loginIDField != "" {
slog.Debug("[UpdateMe] Login ID sync active", "field", loginIDField)
// Search in Metadata (could be flat or namespaced)
var newLoginID string
if val, exists := req.Metadata[loginIDField]; exists {
if loginIDStr, ok := val.(string); ok && loginIDStr != "" {
traits["id"] = loginIDStr
if s, ok := val.(string); ok {
newLoginID = s
}
} else if namespaced, exists := req.Metadata[tenant.ID]; exists {
if subMeta, ok := namespaced.(map[string]any); ok {
if val, exists := subMeta[loginIDField]; exists {
if loginIDStr, ok := val.(string); ok && loginIDStr != "" {
traits["id"] = loginIDStr
if s, ok := val.(string); ok {
newLoginID = s
}
}
}
}
if newLoginID != "" {
slog.Info("[UpdateMe] Syncing custom field to LoginID", "field", loginIDField, "value", newLoginID)
traits["id"] = newLoginID
}
}
}
}