PHPGangsta / GoogleAuthenticator

PHP class to generate and verify Google Authenticator 2-factor authentication
http://phpgangsta.de/4376
BSD 2-Clause "Simplified" License
2.23k stars 689 forks source link

recaptcha v2 not work #90

Open amidevous opened 3 years ago

amidevous commented 3 years ago

recaptcha v2 has not worked for several days it returns

Google reCAPTCHA verification failed! Please try again.

I check the secret and secret key are correct the box and tick and green

and yet it returns this error

amidevous commented 3 years ago

ok solved google change method get by post

change code

$rGA = new PHPGangsta_GoogleAuthenticator();
if ((isset($_POST["username"])) && (isset($_POST["password"]))) {
    if ($rAdminSettings["recaptcha_enable"]) {
        $rResponse = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$rAdminSettings["recaptcha_v2_secret_key"].'&response='.$_POST['g-recaptcha-response']), True);
        if ((!$rResponse["success"]) && (!in_array("invalid-input-secret", $rResponse["error-codes"]))) {
            $_STATUS = 5;
        }
    }

by

$rGA = new PHPGangsta_GoogleAuthenticator();
if ((isset($_POST["username"])) && (isset($_POST["password"]))) {
    if ($rAdminSettings["recaptcha_enable"]) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, 'secret='.$rAdminSettings["recaptcha_v2_secret_key"].'&response='.$_POST['g-recaptcha-response']);
        $response = curl_exec($ch);
        curl_close($ch);
        $rResponse = json_decode($response, True);
        if ((!$rResponse["success"]) && (!in_array("invalid-input-secret", $rResponse["error-codes"]))) {
            $_STATUS = 5;
        }
    }