History

refactor(api): simplify codex id token claims extraction

hkfires committed 10 months agov6.6.67

Commit 30991141 parent a38a9c01 file · +3 −16Browse files

Unified · Split

internal/api/handlers/management/auth_files.go+3−16
@@ -454,25 +454,12 @@ func extractCodexIDTokenClaims(auth *coreauth.Auth) gin.H { · 453 unmodified lines
454 }454 }
455 455
456 result := gin.H{}456 result := gin.H{}
457 if v := strings.TrimSpace(claims.CodexAuthInfo.ChatgptAccountID); v != "" {
458 result["chatgpt_account_id"] = v
459 }
457 if v := strings.TrimSpace(claims.CodexAuthInfo.ChatgptPlanType); v != "" {460 if v := strings.TrimSpace(claims.CodexAuthInfo.ChatgptPlanType); v != "" {
458 result["plan_type"] = v461 result["plan_type"] = v
459 }462 }
460 if v := strings.TrimSpace(claims.CodexAuthInfo.UserID); v != "" {
461 result["user_id"] = v
462 }
463
464 if len(claims.CodexAuthInfo.Organizations) > 0 {
465 orgs := make([]gin.H, 0, len(claims.CodexAuthInfo.Organizations))
466 for _, org := range claims.CodexAuthInfo.Organizations {
467 orgs = append(orgs, gin.H{
468 "id": strings.TrimSpace(org.ID),
469 "title": strings.TrimSpace(org.Title),
470 "role": strings.TrimSpace(org.Role),
471 "is_default": org.IsDefault,
472 })
473 }
474 result["organizations"] = orgs
475 }
476 463
477 if len(result) == 0 {464 if len(result) == 0 {
478 return nil465 return nil