protected function validateCaptchaFromRequest(RequestInterface $request, ResponseInterface &$response = null)
    {
        $token = $request->getParam('g-recaptcha-response', false);
        if (empty($token)) {
            if ($response !== null) {
                $this->addFeedback('error', $this->translator()->translate('Missing CAPTCHA response.'));
                $this->setSuccess(false);

                $response = $response->withStatus(400);
            }

            return false;
        }

        $result = $this->validateCaptcha($token);
        if ($result === false && $response !== null) {
            $this->addFeedback('error', $this->translator()->translate('Invalid or malformed CAPTCHA response.'));
            $this->setSuccess(false);

            $response = $response->withStatus(400);
        }

        return $result;
    }