Skip to content

Commit

Permalink
feat: return validation failed error if captcha request was not json
Browse files Browse the repository at this point in the history
  • Loading branch information
hf committed Oct 25, 2024
1 parent 6ac5624 commit 37e6514
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/api/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 37e6514

Please sign in to comment.