Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/api/handlers/management/auth_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,12 @@ func extractCodexIDTokenClaims(auth *coreauth.Auth) gin.H {
if v := strings.TrimSpace(claims.CodexAuthInfo.ChatgptPlanType); v != "" {
result["plan_type"] = v
}
if v := claims.CodexAuthInfo.ChatgptSubscriptionActiveStart; v != nil {
result["chatgpt_subscription_active_start"] = v
}
if v := claims.CodexAuthInfo.ChatgptSubscriptionActiveUntil; v != nil {
result["chatgpt_subscription_active_until"] = v
}
Comment on lines +463 to +468
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To reduce code repetition and improve maintainability, you could use a map and a loop to add these claims to the result. This approach is more scalable if more claims need to be added in the future.

	for key, value := range map[string]any{
		"chatgpt_subscription_active_start": claims.CodexAuthInfo.ChatgptSubscriptionActiveStart,
		"chatgpt_subscription_active_until": claims.CodexAuthInfo.ChatgptSubscriptionActiveUntil,
	} {
		if value != nil {
			result[key] = value
		}
	}


if len(result) == 0 {
return nil
Expand Down