FRE-4763: Fix Clone() context argument and apply Code Reviewer P0-P3 fixes

- P0: Update auth header after token refresh via GetSession() + SetAuthHeader()
- P2: Unconditional req.WithContext(ctx) instead of fragile context.Background() check
- Fix: req.Clone(ctx) takes context.Context, not *http.Request (req.WithContext(ctx))
- Remove unused checkAuthenticated() and NewRequestWithContext() helpers
This commit is contained in:
2026-05-10 18:06:16 -04:00
parent 2b8051efb1
commit c8ffe76688
2 changed files with 9 additions and 31 deletions

View File

@@ -15,22 +15,6 @@ import (
"github.com/spf13/cobra"
)
func checkAuthenticated() (*auth.Session, error) {
sessionMgr, err := auth.NewSessionManager()
if err != nil {
return nil, fmt.Errorf("failed to create session manager: %w", err)
}
authenticated, err := sessionMgr.IsAuthenticated()
if err != nil || !authenticated {
return nil, fmt.Errorf("not authenticated (run 'pop login' first): %w", err)
}
session, err := sessionMgr.GetSession()
if err != nil {
return nil, fmt.Errorf("not authenticated: %w", err)
}
return session, nil
}
func checkAuthenticatedWithManager() (*auth.Session, *auth.SessionManager, error) {
sessionMgr, err := auth.NewSessionManager()
if err != nil {