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:
16
cmd/mail.go
16
cmd/mail.go
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user