vendor/uvdesk/core-framework/Services/ReCaptchaService.php line 50

Open in your IDE?
  1. <?php
  2. namespace Webkul\UVDesk\CoreFrameworkBundle\Services;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Symfony\Component\HttpFoundation\RequestStack;
  5. use Symfony\Component\DependencyInjection\ContainerInterface;
  6. use Webkul\UVDesk\CoreFrameworkBundle\Entity\Recaptcha;
  7. class ReCaptchaService {
  8.     private $request;
  9.     protected $container;
  10.     protected $em;
  11.     public function __construct(EntityManagerInterface $emRequestStack $requestContainerInterface $container)
  12.     {
  13.         $this->em $em;
  14.         $this->request $request;
  15.         $this->container $container;
  16.     }
  17.     /**
  18.      * Get ReCaptcha Response
  19.      * //g-recaptcha-response
  20.      * @return /Serialize Obj
  21.      */
  22.     public function getReCaptchaResponse($gRecaptchaResponse)
  23.     {  
  24.         $recaptcha = new \ReCaptcha\ReCaptcha($this->getSecretKeyRecaptcha());
  25.         $resp $recaptcha->verify($gRecaptchaResponse$this->request->getCurrentRequest()->headers->get('host'));
  26.         if ($resp->isSuccess()) {
  27.             // verified!
  28.             return false;
  29.         } else {
  30.             return $resp->getErrorCodes();
  31.         }
  32.     }
  33.     public function getSecretKeyRecaptcha()
  34.     {   
  35.         $recaptchaDetail $this->getRecaptchaDetails();
  36.         return $recaptchaDetail->getSecretKey();
  37.     }
  38.     public function getRecaptchaDetails()
  39.     {   
  40.         // find Recaptcha details
  41.         $em $this->em;
  42.         $recaptchaRepo $em->getRepository(Recaptcha::class);
  43.         $recaptcha $recaptchaRepo->findOneById(1);
  44.         return $recaptcha $recaptcha '';
  45.     }
  46. }