MAPG-242 add possibility to captcha validation

This commit is contained in:
bence committed 2022-05-26 18:39:33 +02:00
1 parent 6014e4517a
commit d0751017db
2 files changed
+21

No files matched your search

+2
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
+19
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);
}
}