From 37e6514cdc07ee0fc8e9960643acce98f8b51f28 Mon Sep 17 00:00:00 2001 From: Stojan Dimitrovski Date: Fri, 25 Oct 2024 12:37:02 +0200 Subject: [PATCH] feat: return validation failed error if captcha request was not json --- internal/api/middleware.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/api/middleware.go b/internal/api/middleware.go index 30f19e3ad6..853b8d528d 100644 --- a/internal/api/middleware.go +++ b/internal/api/middleware.go @@ -118,6 +118,10 @@ func (a *API) verifyCaptcha(w http.ResponseWriter, req *http.Request) (context.C verificationResult, err := security.VerifyRequest(req, strings.TrimSpace(config.Security.Captcha.Secret), config.Security.Captcha.Provider) if err != nil { + if strings.Contains(err.Error(), "request body was not JSON") { + return nil, badRequestError(ErrorCodeValidationFailed, "Request body for CAPTCHA verification was not a valid JSON object") + } + return nil, internalServerError("captcha verification process failed").WithInternalError(err) }