[Vuejs]-Where to handle reCAPTCHA? In JavaScript or in PHP?

0👍

This is a class method that I use. The argument ($gRecaptchaResponse) is what is returned by google when you submit the captcha using javascript

protected function validateGoogleRecaptcha($gRecaptchaResponse)
{

    $secretKey = $this->config['application']['captcha']['recaptcha']['secretKey'];
    $reCaptcha = new \ReCaptcha($secretKey);

    $response = $reCaptcha->verifyResponse(
        $_SERVER["REMOTE_ADDR"],
        $gRecaptchaResponse
    );

    return $response;
}

Leave a comment