Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI login: don't print success message unless actually logged in #10

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ If the browser does not open, please visit the following URL:
console := &console{}

var loginErr error
var loggedIn bool

p := tea.NewProgram(newSpinnerModel("Logging in...", func() (tea.Msg, error) {
err := console.Login(token)
loginErr = err
return nil, err
if err := console.Login(token); err != nil {
loginErr = err
return nil, err
}
loggedIn = true
return nil, nil
}))
if _, err = p.Run(); err != nil {
return err
Expand All @@ -53,14 +57,13 @@ If the browser does not open, please visit the following URL:
if loginErr != nil {
failure("Authentication failed. Please contact support at [email protected]")
fmt.Printf("Error: %s\n", loginErr)
return nil
} else if loggedIn {
success("Authentication successful")
fmt.Printf(
"Configuration file created at %s\n",
os.ExpandEnv("$HOME/.dispatch.toml"),
)
}

success("Authentication successful")
fmt.Printf(
"Configuration file created at %s\n",
os.ExpandEnv("$HOME/.dispatch.toml"),
)
return nil
},
}
Expand Down
Loading