From 781f245a904870c5d569a5eabacdb8a835b4f931 Mon Sep 17 00:00:00 2001 From: Chris Scott Date: Wed, 28 Apr 2021 15:27:05 -0400 Subject: [PATCH] Update messaging for login command to be more clear on the next step. Use a spinner while waiting for login to complete in the browser. (#268) --- internal/cli/login.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/internal/cli/login.go b/internal/cli/login.go index a66a418c4..e885c8565 100644 --- a/internal/cli/login.go +++ b/internal/cli/login.go @@ -35,9 +35,8 @@ func RunLogin(ctx context.Context, cli *cli, expired bool) error { if expired { cli.renderer.Warnf("Please sign in to re-authorize the CLI.") } else { - cli.renderer.Infof("✪ Welcome to the Auth0 CLI 🎊.") - cli.renderer.Infof("To set it up, you will need to sign in to your Auth0 account and authorize the CLI to access the API.") - cli.renderer.Infof("If you don't have an account, please go to https://auth0.com/signup, otherwise continue in the browser.\n\n") + fmt.Print("✪ Welcome to the Auth0 CLI 🎊\n\n") + fmt.Print("If you don't have an account, please go to https://auth0.com/signup\n\n") } a := &auth.Authenticator{} @@ -46,21 +45,26 @@ func RunLogin(ctx context.Context, cli *cli, expired bool) error { return fmt.Errorf("could not start the authentication process: %w.", err) } - cli.renderer.Infof("Your pairing code is: %s\n", ansi.Bold(state.UserCode)) - cli.renderer.Infof("This pairing code verifies your authentication with Auth0.") - cli.renderer.Infof("Press Enter to open the browser (^C to quit)") + fmt.Printf("Your Device Confirmation code is: %s\n\n", ansi.Bold(state.UserCode)) + cli.renderer.Infof("%s to open the browser to log in or %s to quit...", ansi.Green("Press Enter"), ansi.Red("^C")) fmt.Scanln() - err = open.URL(state.VerificationURI) + if err != nil { cli.renderer.Warnf("Couldn't open the URL, please do it manually: %s.", state.VerificationURI) } - res, err := a.Wait(ctx, state) + var res auth.Result + err = ansi.Spinner("Waiting for login to complete in browser", func() error { + res, err = a.Wait(ctx, state) + return err + }) + if err != nil { return fmt.Errorf("login error: %w", err) } + fmt.Print("\n") cli.renderer.Infof("Successfully logged in.") cli.renderer.Infof("Tenant: %s\n", res.Domain)