mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 09:23:09 -06:00
Fix defer linting
Signed-off-by: Andrew (anoa) <anoa@openmailbox.org>
This commit is contained in:
parent
9146cebc9f
commit
d2154482dc
|
|
@ -162,6 +162,7 @@ func validatePassword(password string) *util.JSONResponse {
|
||||||
|
|
||||||
// validateRecaptcha returns an error response if the captcha response is invalid
|
// validateRecaptcha returns an error response if the captcha response is invalid
|
||||||
func validateRecaptcha(
|
func validateRecaptcha(
|
||||||
|
req *http.Request,
|
||||||
cfg *config.Dendrite,
|
cfg *config.Dendrite,
|
||||||
response string,
|
response string,
|
||||||
clientip 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
|
// Grab the body of the response from the captcha server
|
||||||
var r recaptchaResponse
|
var r recaptchaResponse
|
||||||
|
|
@ -281,7 +291,7 @@ func Register(
|
||||||
}).Info("Submitting recaptcha response")
|
}).Info("Submitting recaptcha response")
|
||||||
|
|
||||||
// Check given captcha 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 *resErr
|
||||||
}
|
}
|
||||||
return completeRegistration(req.Context(), accountDB, deviceDB,
|
return completeRegistration(req.Context(), accountDB, deviceDB,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue