From 7c5d64b4783c2bf05587b3a4672b35c1e32066c7 Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Wed, 15 Sep 2021 19:12:31 +0200 Subject: Fix /auth compat endpoint Signed-off-by: Matej Vasek --- pkg/api/handlers/compat/auth.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'pkg/api') diff --git a/pkg/api/handlers/compat/auth.go b/pkg/api/handlers/compat/auth.go index 2244adc3d..cf53e060c 100644 --- a/pkg/api/handlers/compat/auth.go +++ b/pkg/api/handlers/compat/auth.go @@ -50,9 +50,19 @@ func Auth(w http.ResponseWriter, r *http.Request) { Status: "Login Succeeded", }) } else { - utils.WriteResponse(w, http.StatusBadRequest, entities.AuthReport{ - IdentityToken: "", - Status: "login attempt to " + authConfig.ServerAddress + " failed with status: " + err.Error(), + var msg string + + var unauthErr DockerClient.ErrUnauthorizedForCredentials + if errors.As(err, &unauthErr) { + msg = "401 Unauthorized" + } else { + msg = err.Error() + } + + utils.WriteResponse(w, http.StatusInternalServerError, struct { + Message string `json:"message"` + }{ + Message: "login attempt to " + authConfig.ServerAddress + " failed with status: " + msg, }) } } -- cgit v1.2.3-54-g00ecf