Merge pull request #877 from zhiqing0205/main

feat(codex): include plan type in auth filename
This commit is contained in:
Luis Pater
2026-01-20 11:11:25 +08:00
committed by GitHub
3 changed files with 67 additions and 3 deletions

View File

@@ -1383,9 +1383,11 @@ func (h *Handler) RequestCodexToken(c *gin.Context) {
claims, _ := codex.ParseJWTToken(tokenResp.IDToken)
email := ""
accountID := ""
planType := ""
if claims != nil {
email = claims.GetUserEmail()
accountID = claims.GetAccountID()
planType = strings.TrimSpace(claims.CodexAuthInfo.ChatgptPlanType)
}
// Build bundle compatible with existing storage
bundle := &codex.CodexAuthBundle{
@@ -1402,10 +1404,11 @@ func (h *Handler) RequestCodexToken(c *gin.Context) {
// Create token storage and persist
tokenStorage := openaiAuth.CreateTokenStorage(bundle)
fileName := codex.CredentialFileName(tokenStorage.Email, planType, true)
record := &coreauth.Auth{
ID: fmt.Sprintf("codex-%s.json", tokenStorage.Email),
ID: fileName,
Provider: "codex",
FileName: fmt.Sprintf("codex-%s.json", tokenStorage.Email),
FileName: fileName,
Storage: tokenStorage,
Metadata: map[string]any{
"email": tokenStorage.Email,