mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-03-09 15:25:17 +00:00
fix(copilot): add username fallback and consistent file name prefix
- Add 'github-user' fallback in WaitForAuthorization when FetchUserInfo returns empty Login (fixes malformed 'github-copilot-.json' filenames) - Standardize Web API file name to 'github-copilot-<user>.json' to match CLI path convention (was 'github-<user>.json') Addresses Gemini Code Assist review comments on PR #291.
This commit is contained in:
@@ -1974,7 +1974,7 @@ func (h *Handler) RequestGitHubToken(c *gin.Context) {
|
||||
Type: "github-copilot",
|
||||
}
|
||||
|
||||
fileName := fmt.Sprintf("github-%s.json", username)
|
||||
fileName := fmt.Sprintf("github-copilot-%s.json", username)
|
||||
label := userInfo.Email
|
||||
if label == "" {
|
||||
label = username
|
||||
|
||||
@@ -87,9 +87,14 @@ func (c *CopilotAuth) WaitForAuthorization(ctx context.Context, deviceCode *Devi
|
||||
log.Warnf("copilot: failed to fetch user info: %v", err)
|
||||
}
|
||||
|
||||
username := userInfo.Login
|
||||
if username == "" {
|
||||
username = "github-user"
|
||||
}
|
||||
|
||||
return &CopilotAuthBundle{
|
||||
TokenData: tokenData,
|
||||
Username: userInfo.Login,
|
||||
Username: username,
|
||||
Email: userInfo.Email,
|
||||
Name: userInfo.Name,
|
||||
}, nil
|
||||
|
||||
Reference in New Issue
Block a user