Skip to content

Commit

Permalink
Merge pull request #10 from stealthrocket/tweak-login-flow
Browse files Browse the repository at this point in the history
CLI login: don't print success message unless actually logged in
  • Loading branch information
chriso authored Apr 16, 2024
2 parents cef264b + 4ae452c commit d5b3dc5
Showing 1 changed file with 13 additions and 10 deletions.
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

0 comments on commit d5b3dc5

Please sign in to comment.