From 4ae452c1de03042fdaf81fc0a368c7ba1a2d5344 Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Tue, 16 Apr 2024 13:15:43 +1000 Subject: [PATCH] Don't print success message unless actually logged in --- cli/login.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cli/login.go b/cli/login.go index d6c181b..a50735b 100644 --- a/cli/login.go +++ b/cli/login.go @@ -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 support@dispatch.run") 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 }, }