MAPG-242 add possibility to captcha validation

This commit is contained in:
Bence Pőcze 2022-05-26 18:39:33 +02:00
parent 6014e4517a
commit d0751017db
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D
2 changed files with 21 additions and 0 deletions

View File

@ -21,3 +21,5 @@ MULTI_INTERNAL_PORT=5000
MULTI_WS_URL=mapguesser-dev.ch:8090
MULTI_WS_PORT=8090
ENABLE_GAME_FOR_GUESTS=0
RECAPTCHA_SITEKEY=your_recaptcha_sitekey
RECAPTCHA_SECRET=your_recaptcha_secret

View File

@ -0,0 +1,19 @@
<?php namespace MapGuesser\Util;
use MapGuesser\Http\Request;
class CaptchaValidator
{
public function validate(string $response)
{
$request = new Request('https://www.google.com/recaptcha/api/siteverify', Request::HTTP_GET);
$request->setQuery([
'secret' => $_ENV['RECAPTCHA_SECRET'],
'response' => $response
]);
$response = $request->send();
return json_decode($response->getBody(), true);
}
}