Refactor token management, client initialization, and project handling
goreleaser / goreleaser (push) Has been cancelled

- Consolidated `TokenStorage` struct into `internal/auth/models.go` for better organization.
- Updated `Client` to use `TokenStorage` for managing email and project ID.
- Simplified `SetupUser` method to ensure proper token and project assignment.
- Refactored API handlers to leverage new `GetEmail` and `GetProjectID` methods in `Client`.
- Cleanup: Removed unused structures and redundant code from `client.go` and `auth.go`.
- Adjusted CLI flow in `login.go` and `run.go` for streamlined user onboarding.
This commit is contained in:
Luis Pater
2025-07-04 17:08:58 +08:00
parent 57ead9a4bc
commit 582280f4c5
7 changed files with 116 additions and 130 deletions
+2 -3
View File
@@ -29,7 +29,7 @@ func DoLogin(cfg *config.Config, projectID string) {
// 3. Initialize CLI Client
cliClient := client.NewClient(httpClient, &ts, cfg)
projectID, err = cliClient.SetupUser(clientCtx, ts.Email, projectID)
err = cliClient.SetupUser(clientCtx, ts.Email, projectID)
if err != nil {
if err.Error() == "failed to start user onboarding, need define a project id" {
log.Error("failed to start user onboarding")
@@ -52,8 +52,7 @@ func DoLogin(cfg *config.Config, projectID string) {
log.Fatalf("failed to complete user setup: %v", err)
}
} else {
auto := ts.ProjectID == ""
cliClient.SetProjectID(projectID)
auto := projectID == ""
cliClient.SetIsAuto(auto)
if !cliClient.IsChecked() && !cliClient.IsAuto() {