From e9f69af6709cbab55cb0ae4c51ed5b0b23c7f3fd Mon Sep 17 00:00:00 2001 From: Neal Date: Fri, 24 Jan 2020 08:11:52 -0600 Subject: [PATCH] fix(login): fix crash with using resp before error check (#47) --- cmd/login.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/login.go b/cmd/login.go index 29237f8f..8b0aba97 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -88,6 +88,9 @@ func authenticate(c *cli.Context) error { } auth, resp, err := client.Authorization.Login(&req) + if err != nil { + return err + } // If user hits an endpoint other than the // Vela server that can't process request @@ -95,9 +98,6 @@ func authenticate(c *cli.Context) error { if http.StatusUnauthorized < resp.StatusCode { return fmt.Errorf("unable to process request") } - if resp.StatusCode != http.StatusUnauthorized && err != nil { - return err - } // retry authentication in case user requires an OTP code switch resp.StatusCode {