Refactor token management, client initialization, and project handling
goreleaser / goreleaser (push) Has been cancelled
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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user