Skip to content

Commit

Permalink
fix panic on native auth
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Sep 19, 2024
1 parent d3de9bf commit 8de6465
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tsuru/auth/native.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ func nativeLogin(ctx *cmd.Context) error {
return err
}
defer response.Body.Close()

if response.StatusCode != http.StatusOK {
body, err := io.ReadAll(response.Body)

Check failure on line 57 in tsuru/auth/native.go

View workflow job for this annotation

GitHub Actions / lint

shadow: declaration of "err" shadows declaration at line 33 (govet)

Check failure on line 57 in tsuru/auth/native.go

View workflow job for this annotation

GitHub Actions / lint

shadow: declaration of "err" shadows declaration at line 33 (govet)
if err != nil {
return err
}
return fmt.Errorf("failed to authenticate user: %s, %s", response.Status, string(body))
}

result, err := io.ReadAll(response.Body)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions tsuru/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func buildManagerCustom(name string, stdout, stderr io.Writer) *cmd.Manager {
fmt.Fprintln(os.Stderr, "trying to login again")
c := &auth.Login{}
loginErr := c.Run(&cmd.Context{
Stdin: os.Stdin,
Stderr: stderr,
Stdout: stdout,
})
Expand Down

0 comments on commit 8de6465

Please sign in to comment.