-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from stealthrocket/tweak-login-flow
CLI login: don't print success message unless actually logged in
- Loading branch information
Showing
1 changed file
with
13 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
}, | ||
} | ||
|