MAPG-242 add possibility to captcha validation
This commit is contained in:
parent
6014e4517a
commit
d0751017db
@ -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
src/Util/CaptchaValidator.php
Normal file
19
src/Util/CaptchaValidator.php
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user