src/Charcoal/Admin/AdminAction.php
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;
    }
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;
    }
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 ; }
Validate a Google reCAPTCHA user response from a PSR Request object.

@param  RequestInterface       $request  A PSR-7 compatible Request instance.
@param  ResponseInterface|null $response A PSR-7 compatible Response instance.
If $response is provided and challenge fails, then it is replaced
with a new Response object that represents a client error.
@return boolean Returns TRUE if the user response is valid, FALSE if it is invalid.
Validate a Google reCAPTCHA user response from a PSR Request object .