Fix defer linting

Signed-off-by: Andrew (anoa) <anoa@openmailbox.org>
This commit is contained in:
Andrew (anoa) 2017-11-17 00:12:52 -08:00
parent 9146cebc9f
commit d2154482dc
No known key found for this signature in database
GPG key ID: 174BEAB009FD176D

View file

@ -162,6 +162,7 @@ func validatePassword(password string) *util.JSONResponse {
// validateRecaptcha returns an error response if the captcha response is invalid
func validateRecaptcha(
req *http.Request,
cfg *config.Dendrite,
response string,
clientip string,
@ -189,7 +190,16 @@ func validateRecaptcha(
}
}
defer resp.Body.Close()
defer func() {
err := resp.Body.Close()
if err != nil {
logger := util.GetLogger(req.Context())
logger.WithFields(log.Fields{
"response": response,
}).Info("Failed to close recaptcha request response body")
}
}()
// Grab the body of the response from the captcha server
var r recaptchaResponse
@ -281,7 +291,7 @@ func Register(
}).Info("Submitting recaptcha response")
// Check given captcha response
if resErr = validateRecaptcha(cfg, r.Auth.Response, req.RemoteAddr); resErr != nil {
if resErr = validateRecaptcha(req, cfg, r.Auth.Response, req.RemoteAddr); resErr != nil {
return *resErr
}
return completeRegistration(req.Context(), accountDB, deviceDB,