Source of file GoogleReCaptchaController.php
Size: 0,888 Bytes - Last Modified: 2021-12-24T06:43:41+00:00
/var/www/docs.ssmods.com/process/src/code/controllers/GoogleReCaptchaController.php
1234567891011121314151617181920212223242526272829303132333435 | <?php use SilverStripe\Core\Config\Config; use SilverStripe\Control\Controller; use guzzlehttp\guzzle; class GoogleReCaptchaController extends Controller { private static $allowed_actions = [ 'verify', ]; public function verify() { $request = $this->getRequest(); $userResponse = $request->postVar('userResponse'); $apiEndpoint = Config::inst()->get('GoogleReCaptchaController', 'verification_endpoint'); $client = new GuzzleHttp\Client(); $res = $client->request('GET', $apiEndpoint, [ 'query' => [ 'secret' => $this->getRecaptchaSecretKey(), 'response' => $userResponse, ] ]); return $res->getBody()->getContents(); } private function getRecaptchaSecretKey() { return Config::inst()->get('GoogleReCaptcha', 'secret_key'); } } |