diff --git a/internal/api/handlers/management/auth_files.go b/internal/api/handlers/management/auth_files.go index df5456b9..91e1c425 100644 --- a/internal/api/handlers/management/auth_files.go +++ b/internal/api/handlers/management/auth_files.go @@ -3705,7 +3705,7 @@ func (h *Handler) RequestCursorToken(c *gin.Context) { ctx = PopulateAuthContext(ctx, c) label := strings.TrimSpace(c.Query("label")) - fmt.Printf("Initializing Cursor authentication (label=%q)...\n", label) + log.Infof("Initializing Cursor authentication (label=%q)...", label) authParams, err := cursorauth.GenerateAuthParams() if err != nil { @@ -3718,13 +3718,13 @@ func (h *Handler) RequestCursorToken(c *gin.Context) { RegisterOAuthSession(state, "cursor") go func() { - fmt.Println("Waiting for Cursor authentication...") - fmt.Printf("Open this URL in your browser: %s\n", authParams.LoginURL) + log.Info("Waiting for Cursor authentication...") + log.Infof("Open this URL in your browser: %s", authParams.LoginURL) tokens, errPoll := cursorauth.PollForAuth(ctx, authParams.UUID, authParams.Verifier) if errPoll != nil { SetOAuthSessionError(state, "Authentication failed: "+errPoll.Error()) - fmt.Printf("Cursor authentication failed: %v\n", errPoll) + log.Errorf("Cursor authentication failed: %v", errPoll) return } @@ -3761,7 +3761,7 @@ func (h *Handler) RequestCursorToken(c *gin.Context) { return } - fmt.Printf("Cursor authentication successful! Token saved to %s\n", savedPath) + log.Infof("Cursor authentication successful! Token saved to %s", savedPath) CompleteOAuthSession(state) CompleteOAuthSessionsByProvider("cursor") }() diff --git a/internal/cmd/cursor_login.go b/internal/cmd/cursor_login.go index 0ffdef1b..edebfec0 100644 --- a/internal/cmd/cursor_login.go +++ b/internal/cmd/cursor_login.go @@ -2,7 +2,6 @@ package cmd import ( "context" - "fmt" "github.com/router-for-me/CLIProxyAPI/v6/internal/config" sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth" @@ -29,10 +28,10 @@ func DoCursorLogin(cfg *config.Config, options *LoginOptions) { } if savedPath != "" { - fmt.Printf("Authentication saved to %s\n", savedPath) + log.Infof("Authentication saved to %s", savedPath) } if record != nil && record.Label != "" { - fmt.Printf("Authenticated as %s\n", record.Label) + log.Infof("Authenticated as %s", record.Label) } - fmt.Println("Cursor authentication successful!") + log.Info("Cursor authentication successful!") } diff --git a/sdk/auth/cursor.go b/sdk/auth/cursor.go index 86cad880..d6077be6 100644 --- a/sdk/auth/cursor.go +++ b/sdk/auth/cursor.go @@ -47,8 +47,8 @@ func (a CursorAuthenticator) Login(ctx context.Context, cfg *config.Config, opts } // Display the login URL - fmt.Println("Starting Cursor authentication...") - fmt.Printf("\nPlease visit this URL to log in:\n%s\n\n", authParams.LoginURL) + log.Info("Starting Cursor authentication...") + log.Infof("Please visit this URL to log in: %s", authParams.LoginURL) // Try to open the browser automatically if !opts.NoBrowser { @@ -59,7 +59,7 @@ func (a CursorAuthenticator) Login(ctx context.Context, cfg *config.Config, opts } } - fmt.Println("Waiting for Cursor authorization...") + log.Info("Waiting for Cursor authorization...") // Poll for the auth result tokens, err := cursorauth.PollForAuth(ctx, authParams.UUID, authParams.Verifier) @@ -69,7 +69,7 @@ func (a CursorAuthenticator) Login(ctx context.Context, cfg *config.Config, opts expiresAt := cursorauth.GetTokenExpiry(tokens.AccessToken) - fmt.Println("\nCursor authentication successful!") + log.Info("Cursor authentication successful!") metadata := map[string]any{ "type": "cursor",