From 0e3069416404ebbcf7fea1219a7d1c201c266a2f Mon Sep 17 00:00:00 2001 From: yiwata Date: Tue, 7 Jul 2020 14:13:20 +0900 Subject: [PATCH] Trim trailing newlines from verification code using "--console" Fixes #312 --- command/oauth/cmd.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/command/oauth/cmd.go b/command/oauth/cmd.go index 17facd9b..0c346437 100644 --- a/command/oauth/cmd.go +++ b/command/oauth/cmd.go @@ -1,7 +1,6 @@ package oauth import ( - "bufio" "crypto/sha256" "crypto/x509" "encoding/base64" @@ -26,6 +25,7 @@ import ( "github.com/smallstep/cli/exec" "github.com/smallstep/cli/flags" "github.com/smallstep/cli/jose" + "github.com/smallstep/cli/utils" "github.com/urfave/cli" ) @@ -567,8 +567,7 @@ func (o *oauth) DoManualAuthorization() (*token, error) { // Read from the command line fmt.Fprint(os.Stderr, "Enter verification code: ") - reader := bufio.NewReader(os.Stdin) - code, err := reader.ReadString('\n') + code, err := utils.ReadString(os.Stdin) if err != nil { return nil, errors.WithStack(err) }