Skip to content

Commit

Permalink
client: Stops creating client when secret is too short (#764)
Browse files Browse the repository at this point in the history
Previously, clients were created despite an error which said that the secret was too short. This patch changes that and improves error output in the CLI as well for this command.

Closes #725
  • Loading branch information
zepatrik authored and arekkas committed Feb 6, 2018
1 parent 049f581 commit f818f85
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request, _ httprouter.Pa
c.Secret = string(secret)
} else if len(c.Secret) < 6 {
h.H.WriteError(w, r, errors.New("The client secret must be at least 6 characters long"))
return
}

secret := c.Secret
Expand Down
1 change: 1 addition & 0 deletions cmd/cli/handler_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func checkResponse(response *hydra.APIResponse, err error, expectedStatusCode in

if response.StatusCode != expectedStatusCode {
fmt.Fprintf(os.Stderr, "Command failed because status code %d was expeceted but code %d was received.\n", expectedStatusCode, response.StatusCode)
fmt.Fprintf(os.Stderr, "The server responded with:\n%s\n", response.Payload)
os.Exit(1)
return
}
Expand Down

0 comments on commit f818f85

Please sign in to comment.