feat(codex): include plan type in auth filename

This commit is contained in:
zhiqing0205
2026-01-06 02:25:56 +08:00
parent 9f1b445c7c
commit ac3ca0ad8e
3 changed files with 67 additions and 3 deletions

View File

@@ -1377,9 +1377,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{
@@ -1396,10 +1398,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,