forked from baron/baron-sso
fix: UpdateMe 핸들러 내 계층형 메타데이터 처리 및 로그인 ID 동기화 로직 보강
This commit is contained in:
@@ -5283,20 +5283,27 @@ func (h *AuthHandler) UpdateMe(c *fiber.Ctx) error {
|
|||||||
if schemaCompCode != "" && h.TenantService != nil {
|
if schemaCompCode != "" && h.TenantService != nil {
|
||||||
if tenant, err := h.TenantService.GetTenantBySlug(c.Context(), schemaCompCode); err == nil && tenant != nil {
|
if tenant, err := h.TenantService.GetTenantBySlug(c.Context(), schemaCompCode); err == nil && tenant != nil {
|
||||||
if loginIDField, ok := tenant.Config["loginIdField"].(string); ok && loginIDField != "" {
|
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)
|
// Search in Metadata (could be flat or namespaced)
|
||||||
|
var newLoginID string
|
||||||
if val, exists := req.Metadata[loginIDField]; exists {
|
if val, exists := req.Metadata[loginIDField]; exists {
|
||||||
if loginIDStr, ok := val.(string); ok && loginIDStr != "" {
|
if s, ok := val.(string); ok {
|
||||||
traits["id"] = loginIDStr
|
newLoginID = s
|
||||||
}
|
}
|
||||||
} else if namespaced, exists := req.Metadata[tenant.ID]; exists {
|
} else if namespaced, exists := req.Metadata[tenant.ID]; exists {
|
||||||
if subMeta, ok := namespaced.(map[string]any); ok {
|
if subMeta, ok := namespaced.(map[string]any); ok {
|
||||||
if val, exists := subMeta[loginIDField]; exists {
|
if val, exists := subMeta[loginIDField]; exists {
|
||||||
if loginIDStr, ok := val.(string); ok && loginIDStr != "" {
|
if s, ok := val.(string); ok {
|
||||||
traits["id"] = loginIDStr
|
newLoginID = s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if newLoginID != "" {
|
||||||
|
slog.Info("[UpdateMe] Syncing custom field to LoginID", "field", loginIDField, "value", newLoginID)
|
||||||
|
traits["id"] = newLoginID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user