src/Controller/Website/AbstractWebsiteController.php line 755

Open in your IDE?
  1. <?php
  2. namespace EADPlataforma\Controller\Website;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController as Controller;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\RequestStack;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\RedirectResponse;
  9. use Symfony\Component\Serializer\Encoder\JsonEncoder;
  10. use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
  11. use Symfony\Component\Serializer\Serializer;
  12. use EADPlataforma\Services\GeneralService;
  13. use EADPlataforma\Entity\ConfigurationIp;
  14. use EADPlataforma\Entity\User;
  15. use EADPlataforma\Enum\UserEnum;
  16. use EADPlataforma\Enum\ClientEnum;
  17. use EADPlataforma\Enum\ConfigurationIpEnum;
  18. use EADPlataforma\Enum\ServicesEnum;
  19. use EADPlataforma\Enum\ErrorEnum;
  20. abstract class AbstractWebsiteController extends Controller {
  21.     /**
  22.      * @var GeneralService
  23.      */
  24.     protected $generalService;
  25.     /**
  26.      * @var \MemcacheService
  27.      */
  28.     protected $memcacheService;
  29.     /**
  30.      * @var SchoolEntityManager
  31.      */
  32.     protected $em;
  33.     /**
  34.      * @var SchoolEntityManagerRead
  35.      */
  36.     protected $emRead;
  37.     /**
  38.      * @var EadminEntityManager
  39.      */
  40.     protected $emEadmin;
  41.     /**
  42.      * @var User $user
  43.      */
  44.     protected $user;
  45.     /**
  46.      * @var FileService $fileService
  47.      */
  48.     protected $fileService;
  49.     /**
  50.      * @var LogService $userLogService
  51.      */
  52.     protected $userLogService;
  53.     /**
  54.      * @var ConfigurationService
  55.      */
  56.     protected $configuration;
  57.     /**
  58.      * @var SessionInterface
  59.      */
  60.     protected $sessionSym;
  61.     /**
  62.      * @var EntityUtil $entityUtil
  63.      */
  64.     protected $entityUtil;
  65.     /**
  66.      * @var StringUtil $stringUtil
  67.      */
  68.     protected $stringUtil;
  69.     /**
  70.      * @var UserPermissionUtil $userPermissionUtil
  71.      */
  72.     protected $userPermissionUtil;
  73.     /**
  74.      * @var RequestUtil $requestUtil
  75.      */
  76.     protected $requestUtil;
  77.     /**
  78.      * @var \Client
  79.      */
  80.     protected $client;
  81.     /**
  82.      * @var \ClientConfiguration
  83.      */
  84.     protected $clientConfig;
  85.     /**
  86.      * @var string
  87.      */
  88.     protected $domain;
  89.     /**
  90.      * @var string
  91.      */
  92.     protected $eadDomain;
  93.     /**
  94.      * @var array
  95.      */
  96.     protected $data = [];
  97.     /**
  98.      * @var string
  99.      */
  100.     public $adminLink;
  101.     /**
  102.      * Constructor
  103.      *
  104.      * @param GeneralService $generalService
  105.      * @param RequestStack $requestStack
  106.      */
  107.     public function __construct(GeneralService $generalServiceRequestStack $requestStack){
  108.         $this->generalService $generalService;
  109.         $this->em $this->generalService->getService('SchoolEntityManager');
  110.         $this->emRead $this->generalService->getService('SchoolEntityManagerRead');
  111.         $this->emEadmin $this->generalService->getService('EadminEntityManager');
  112.         
  113.         $this->fileService $this->generalService->getService('FileService');
  114.         $this->userLogService $this->generalService->getService('LogService');
  115.         $this->memcacheService $this->generalService->getService('MemcacheService');
  116.         $this->userPermissionUtil $this->generalService->getUtil('UserPermissionUtil');
  117.         $databaseManagerService $this->generalService->getService('DatabaseManagerService');
  118.         $databaseManagerService->executeMigrations();
  119.         $request $requestStack->getCurrentRequest();
  120.         $this->user $this->generalService->getService('UserSessionService')->getUser();
  121.         $this->configuration $this->generalService->getService('ConfigurationService');
  122.         $this->sessionSym $this->configuration->getSessionSym();
  123.         $this->entityUtil $this->generalService->getUtil('EntityUtil');
  124.         $this->stringUtil $this->generalService->getUtil('StringUtil');
  125.         $this->requestUtil $this->generalService->getUtil('RequestUtil');
  126.         $this->client $this->configuration->getClient();
  127.         $this->clientConfig $this->configuration->getClientConfiguration();
  128.         if($this->client){
  129.             $this->domain $this->configuration->getActiveDomain(true);
  130.             $this->eadDomain $this->client->getDomainPrimary();
  131.             $this->adminLink $this->configuration->getAdminLink();
  132.         }
  133.         if(!$this->generalService->isSandbox()){
  134.             //$this->executeCron($request);
  135.         }
  136.         if($this->configuration->checkModuleIsAbleOnPlan('ipFunction')){
  137.             $this->checkConfigurationIp($request);
  138.         }
  139.         $this->checkPlatformStatus($request);
  140.         $this->checkRedirectDomain($request);
  141.         if($this->isPlatformActive()){
  142.             $this->checkIsRestricted($request);
  143.            $this->checkUserIsComplete($request);
  144.         }
  145.     }
  146.     public function executeCron(Request $request)
  147.     {
  148.         return;
  149.         /*$platformStatus = $this->clientConfig->getPlatformStatus();
  150.         $suspended = ClientEnum::PLATFORM_STATUS_SUSPENDED;
  151.         $canceled = ClientEnum::PLATFORM_STATUS_CANCELED;
  152.         
  153.         if($platformStatus == $suspended || $platformStatus == $canceled){
  154.             return;
  155.         }
  156.         if(
  157.             stristr($request->getPathInfo(), '/general/')
  158.         ){
  159.             return;
  160.         }
  161.         $today = date('Y-m-d H:i:s');
  162.         $lastExecutionDay = $this->configuration->get('cron_date');
  163.         $cronUrl = "https://{$this->eadDomain}/general/{$this->clientConfig->getToken()}";
  164.         if(!empty($lastExecutionDay)){
  165.             $todaySeconds = strtotime($today);
  166.             $lastExecutionSeconds = strtotime($lastExecutionDay);
  167.             $diff = $todaySeconds - $lastExecutionSeconds;
  168.             $diffHours = round($diff / 60 / 60);
  169.             
  170.             if($diffHours >= 24){
  171.                 $sqsService = $this->generalService->getService('Aws\\AwsSqs');
  172.                 $sqsService->sendMessageCron($cronUrl);
  173.                 sleep(5);
  174.             }
  175.         }else{
  176.             $hour = rand(7,9);
  177.             $min = rand(10,59);
  178.             $date = date('Y-m-d');
  179.             $this->configuration->set('cron_date', "{$date} 0{$hour}:{$min}:00", false);
  180.         }*/
  181.     }
  182.     public function checkConfigurationIp(Request $request)
  183.     {
  184.         $info $this->generalService->getServiceAccess(ServicesEnum::LOGIN);
  185.         if(!in_array($request->getClientIp(), $info->validIps)){
  186.             $configuration $this->generalService->getService('ConfigurationService');
  187.             
  188.             $configurationIpRepository $this->em->getRepository(ConfigurationIp::class);
  189.             $configurationIp $configurationIpRepository->findOneBy([
  190.                 "ip" => $request->getClientIp(),
  191.                 "deleted" => ConfigurationIpEnum::ITEM_NO_DELETED 
  192.             ]);
  193.             $countWhitelist $configurationIpRepository->count([
  194.                 "type" => ConfigurationIpEnum::WHITE_LIST,
  195.                 "deleted" => ConfigurationIpEnum::ITEM_NO_DELETED 
  196.             ]);
  197.             if($configurationIp){
  198.                 if($configurationIp->getType() == ConfigurationIpEnum::BLACK_LIST){
  199.                     $response = new Response(''Response::HTTP_UNAUTHORIZED);
  200.                     $response->send();
  201.                     exit;
  202.                 }
  203.             }elseif(!empty($countWhitelist)){
  204.                 $response = new Response(''Response::HTTP_UNAUTHORIZED);
  205.                 $response->send();
  206.                 exit;
  207.             }
  208.         }
  209.     }
  210.     public function checkRedirectDomain(Request $request)
  211.     {
  212.         $info $this->generalService->getServiceAccess(ServicesEnum::LOGIN);
  213.         if(in_array($request->getClientIp(), $info->validIps)){
  214.             return;
  215.         }
  216.         if($this->configuration->isLocal()){
  217.             return;
  218.         }
  219.         $ignoreRoutes = [
  220.             "genereateAdminSSO",
  221.             "loginEadminSSO",
  222.             "sendCron",
  223.             "manifest",
  224.             "updateLive",
  225.             "meetRecordRegister",
  226.             "sitemap",
  227.             "cronGeneral",
  228.             "callbackVimeo",
  229.             "getTokenAccessRd",
  230.             "executeCalculateAnticipation",
  231.             "getEADCheckoutFee",
  232.             "deleteNfeEADCheckout",
  233.             "executeCronListEmail",
  234.             "executeCronUserSubscription",
  235.             "sendWebhookQueue",
  236.             "deleteTrashAll",
  237.             "processDataEadCheckout",
  238.             "processDataEadCheckoutBar",
  239.             "processDataPagSeguro",
  240.             "processDataPagSeguroBar",
  241.             "processDataHotmart",
  242.             "processDataHotmartBar",
  243.             "processDataPayPal",
  244.             "processDataPayPalBar",
  245.             "processDataEduzz",
  246.             "processDataEduzzBar",
  247.             "processDataProvi",
  248.             "processDataProviBar",
  249.             "processDataBraip",
  250.             "processDataBraipBar",
  251.             "processDataMonetizze",
  252.             "processDataMonetizzeBar",
  253.             "processDataKiwify",
  254.             "processDataKiwifyBar",
  255.             "processDataDigitalManagerGuru",
  256.             "processDataDigitalManagerGuruBar",
  257.             "processDataAppMax",
  258.             "processDataAppMaxBar",
  259.             "processDataDoppus",
  260.             "processDataDoppusBar",
  261.             "processDataTicto",
  262.             "processDataTictoBar",
  263.             "processDataMercadoPago",
  264.             "processDataMercadoPagoBar",
  265.             "processDataAbmex",
  266.             "processDataAbmexBar",
  267.             "processDataPerfectPay",
  268.             "processDataPerfectPayBar",
  269.             "processDataEvermart",
  270.             "processDataEvermartBar",
  271.             "processDataHeroSpark",
  272.             "processDataHeroSparkBar",
  273.             "processDataYampi",
  274.             "processDataYampiBar",
  275.             "processDataCartPanda",
  276.             "processDataCartPandaBar",
  277.             "processDataKirvano",
  278.             "processDataKirvanoBar",
  279.             "callbackRdStation",
  280.             "callbackRdStationBar",
  281.             "callbackBling",
  282.             "callbackBlingBar",
  283.             "callbackDinamize",
  284.             "callbackDinamizeBar",
  285.             "cartCheckoutCharge",
  286.             "getRoutesToFileImport",
  287.             "getRoutesToExport",
  288.             "exportCertificate",
  289.             "exportTestimonial",
  290.             "exportEnrollment",
  291.             "exportExamUser",
  292.             "exportExamUserReport",
  293.             "exportLessonLog",
  294.             "exportNewsLetter",
  295.             "exportProductCharge",
  296.             "exportTransaction",
  297.             "exportTransactionItem",
  298.             "exportUser",
  299.             "exportUserSubscription",
  300.             "exportWhishList",
  301.             "exportLessonPresence",
  302.             "exportQuestions",
  303.             "exportProductOpportunity",
  304.             "fileGetUpload",
  305.             "exportLessonSupport",
  306.             "getClientInfo",
  307.             "downgradeToFree",
  308.             "upgradeReceivers",
  309.             "removeClientCustomDomain",
  310.             "getInfo",
  311.             "getInfoCourse",
  312.             "sendAuthenticationEmail"
  313.         ];
  314.         if(in_array($request->get('_route'), $ignoreRoutes)){
  315.             return;
  316.         }
  317.         $gKeyV3 $this->configuration->get('recaptcha_key_v3');
  318.         $gSecretV3 $this->configuration->get('recaptcha_secret_v3');
  319.         $domainPrimary $this->client->getDomainPrimary();
  320.         $domainSecondary $this->client->getDomainSecondary();
  321.         if(
  322.             empty($gKeyV3) || 
  323.             empty($gSecretV3) || 
  324.             !$this->configuration->checkModuleIsAbleOnPlan('domainFunction')
  325.         ){
  326.             if($request->getHost() == $domainSecondary && !empty($domainSecondary)){
  327.                 $url "https://{$domainPrimary}{$request->getPathInfo()}";
  328.                 $redirectResponse = new RedirectResponse($url302);
  329.                 $redirectResponse->send();
  330.                 exit;
  331.             }
  332.         }
  333.         if($this->clientConfig->getRedirect() == ClientEnum::YES){
  334.             if(empty($gKeyV3) || empty($gSecretV3)){
  335.                 return;
  336.             }
  337.             if($request->getHost() == $this->client->getDomainPrimary()){
  338.                 if(!empty($domainSecondary)){
  339.                     $url "https://{$domainSecondary}{$request->getPathInfo()}";
  340.                     $redirectResponse = new RedirectResponse($url301);
  341.                     $redirectResponse->send();
  342.                     exit;
  343.                 }
  344.             }
  345.         }
  346.     }
  347.     public function checkIsRestricted(Request $request)
  348.     {
  349.         if(!$this->user){
  350.             $ignoreRoutes = [
  351.                 "genereateAdminSSO",
  352.                 "loginEadminSSO",
  353.                 "sendCron",
  354.                 "updateLive",
  355.                 "meetRecordRegister",
  356.                 "notFound",
  357.                 "manifest",
  358.                 "sitemap",
  359.                 "authLogin",
  360.                 "authMFA",
  361.                 "sendEmailAuthentication",
  362.                 "updateUserNotification",
  363.                 "sendEmailRecoverPassword",
  364.                 "resetPassword",
  365.                 "login",
  366.                 "loginPost",
  367.                 "loginFast",
  368.                 "loginApi",
  369.                 "loginConfirm",
  370.                 "loginAuthentication",
  371.                 "recoverPassword",
  372.                 "changePasswordPost",
  373.                 "resetPasswordPost",
  374.                 "userLogoff",
  375.                 "logoff ",
  376.                 "getChargePage",
  377.                 "cartCheckoutCharge",
  378.                 "cronGeneral",
  379.                 "callbackVimeo",
  380.                 "getTokenAccessRd",
  381.                 "executeCalculateAnticipation",
  382.                 "getEADCheckoutFee",
  383.                 "deleteNfeEADCheckout",
  384.                 "executeCronListEmail",
  385.                 "executeCronUserSubscription",
  386.                 "sendWebhookQueue",
  387.                 "deleteTrashAll",
  388.                 "processDataEadCheckout",
  389.                 "processDataEadCheckoutBar",
  390.                 "processDataPagSeguro",
  391.                 "processDataPagSeguroBar",
  392.                 "processDataHotmart",
  393.                 "processDataHotmartBar",
  394.                 "processDataPayPal",
  395.                 "processDataPayPalBar",
  396.                 "processDataEduzz",
  397.                 "processDataEduzzBar",
  398.                 "processDataProvi",
  399.                 "processDataProviBar",
  400.                 "processDataBraip",
  401.                 "processDataBraipBar",
  402.                 "processDataMonetizze",
  403.                 "processDataMonetizzeBar",
  404.                 "processDataKiwify",
  405.                 "processDataKiwifyBar",
  406.                 "processDataDigitalManagerGuru",
  407.                 "processDataDigitalManagerGuruBar",
  408.                 "processDataAppMax",
  409.                 "processDataAppMaxBar",
  410.                 "processDataDoppus",
  411.                 "processDataDoppusBar",
  412.                 "processDataTicto",
  413.                 "processDataTictoBar",
  414.                 "processDataMercadoPago",
  415.                 "processDataMercadoPagoBar",
  416.                 "processDataAbmex",
  417.                 "processDataAbmexBar",
  418.                 "processDataPerfectPay",
  419.                 "processDataPerfectPayBar",
  420.                 "processDataEvermart",
  421.                 "processDataEvermartBar",
  422.                 "processDataHeroSpark",
  423.                 "processDataHeroSparkBar",
  424.                 "processDataYampi",
  425.                 "processDataYampiBar",
  426.                 "processDataCartPanda",
  427.                 "processDataCartPandaBar",
  428.                 "processDataKirvano",
  429.                 "processDataKirvanoBar",
  430.                 "callbackRdStation",
  431.                 "callbackRdStationBar",
  432.                 "callbackBling",
  433.                 "callbackBlingBar",
  434.                 "callbackDinamize",
  435.                 "callbackDinamizeBar",
  436.                 "certificateSearchPage",
  437.                 "certificatePage",
  438.                 "stopNotification",
  439.                 "updateUserNotification",
  440.                 "fileGetUpload",
  441.                 "getClientInfo",
  442.                 "downgradeToFree",
  443.                 "upgradeReceivers",
  444.                 "removeClientCustomDomain",
  445.                 "downloadCertificate",
  446.                 "viewCertificate",
  447.                 "getInfo",
  448.                 "getInfoCourse",
  449.                 "sendAuthenticationEmail"
  450.             ];
  451.             $platformType $this->client->getPlatformType();
  452.             if($platformType == ClientEnum::PLATFORM_TYPE_RESTRICTED){
  453.                 if(in_array($request->get('_route'), $ignoreRoutes)){
  454.                     return;
  455.                 }
  456.                 $this->checkUserSession($request);
  457.                 return;
  458.             }
  459.         }
  460.         return;
  461.     }
  462.     public function isPlatformActive()
  463.     {
  464.         $platformStatus $this->clientConfig->getPlatformStatus();
  465.         if($platformStatus == ClientEnum::PLATFORM_STATUS_FREEZED && $this->user){
  466.             return $this->userPermissionUtil->canAccessAdm();
  467.         }
  468.         return ($platformStatus == ClientEnum::PLATFORM_STATUS_ACTIVED);
  469.     }
  470.     public function checkPlatformStatus(Request $request){
  471.         if($this->isPlatformActive()){
  472.             return;
  473.         }
  474.         $platformStatus $this->clientConfig->getPlatformStatus();
  475.         $ignoreRoutes = [
  476.             "genereateAdminSSO",
  477.             "loginEadminSSO",
  478.             "sendCron",
  479.             "updateLive",
  480.             "meetRecordRegister",
  481.             "home",
  482.             "getClientInfo",
  483.             "downgradeToFree",
  484.             "upgradeReceivers",
  485.             "removeClientCustomDomain",
  486.             "fileGetUpload",
  487.             "getInfo",
  488.             "getInfoCourse"
  489.         ];
  490.         if($platformStatus == ClientEnum::PLATFORM_STATUS_FREEZED){
  491.             if($this->user){
  492.                 return;
  493.             }
  494.             $ignoreRoutes[] = "authLogin";
  495.             $ignoreRoutes[] = "authMFA";
  496.             $ignoreRoutes[] = "sendEmailAuthentication";
  497.             $ignoreRoutes[] = "updateUserNotification";
  498.             $ignoreRoutes[] = "sendEmailRecoverPassword";
  499.             $ignoreRoutes[] = "resetPassword";
  500.             $ignoreRoutes[] = "login";
  501.             $ignoreRoutes[] = "loginPost";
  502.             $ignoreRoutes[] = "loginFast";
  503.             $ignoreRoutes[] = "loginApi";
  504.             $ignoreRoutes[] = "loginConfirm";
  505.             $ignoreRoutes[] = "loginAuthentication";
  506.             $ignoreRoutes[] = "recoverPassword";
  507.             $ignoreRoutes[] = "changePasswordPost";
  508.             $ignoreRoutes[] = "resetPasswordPost";
  509.             $ignoreRoutes[] = "userLogoff";
  510.             $ignoreRoutes[] = "logoff";
  511.             $ignoreRoutes[] = "cronGeneral";
  512.             $ignoreRoutes[] = "callbackVimeo";
  513.             $ignoreRoutes[] = "getTokenAccessRd";
  514.             $ignoreRoutes[] = "executeCalculateAnticipation";
  515.             $ignoreRoutes[] = "getEADCheckoutFee";
  516.             $ignoreRoutes[] = "deleteNfeEADCheckout";
  517.             $ignoreRoutes[] = "executeCronListEmail";
  518.             $ignoreRoutes[] = "executeCronUserSubscription";
  519.             $ignoreRoutes[] = "sendWebhookQueue";
  520.             $ignoreRoutes[] = "deleteTrashAll";
  521.             $ignoreRoutes[] = "processDataEadCheckout";
  522.             $ignoreRoutes[] = "processDataEadCheckoutBar";
  523.             $ignoreRoutes[] = "processDataPagSeguro";
  524.             $ignoreRoutes[] = "processDataPagSeguroBar";
  525.             $ignoreRoutes[] = "processDataHotmart";
  526.             $ignoreRoutes[] = "processDataHotmartBar";
  527.             $ignoreRoutes[] = "processDataPayPal";
  528.             $ignoreRoutes[] = "processDataPayPalBar";
  529.             $ignoreRoutes[] = "processDataEduzz";
  530.             $ignoreRoutes[] = "processDataEduzzBar";
  531.             $ignoreRoutes[] = "processDataProvi";
  532.             $ignoreRoutes[] = "processDataProviBar";
  533.             $ignoreRoutes[] = "processDataBraip";
  534.             $ignoreRoutes[] = "processDataBraipBar";
  535.             $ignoreRoutes[] = "processDataMonetizze";
  536.             $ignoreRoutes[] = "processDataMonetizzeBar";
  537.             $ignoreRoutes[] = "processDataKiwify";
  538.             $ignoreRoutes[] = "processDataKiwifyBar";
  539.             $ignoreRoutes[] = "processDataDigitalManagerGuru";
  540.             $ignoreRoutes[] = "processDataDigitalManagerGuruBar";
  541.             $ignoreRoutes[] = "processDataAppMax";
  542.             $ignoreRoutes[] = "processDataAppMaxBar";
  543.             $ignoreRoutes[] = "processDataDoppus";
  544.             $ignoreRoutes[] = "processDataDoppusBar";
  545.             $ignoreRoutes[] = "processDataTicto";
  546.             $ignoreRoutes[] = "processDataTictoBar";
  547.             $ignoreRoutes[] = "processDataMercadoPago";
  548.             $ignoreRoutes[] = "processDataMercadoPagoBar";
  549.             $ignoreRoutes[] = "processDataAbmex";
  550.             $ignoreRoutes[] = "processDataAbmexBar";
  551.             $ignoreRoutes[] = "processDataPerfectPay";
  552.             $ignoreRoutes[] = "processDataPerfectPayBar";
  553.             $ignoreRoutes[] = "processDataEvermart";
  554.             $ignoreRoutes[] = "processDataEvermartBar";
  555.             $ignoreRoutes[] = "processDataHeroSpark";
  556.             $ignoreRoutes[] = "processDataHeroSparkBar";
  557.             $ignoreRoutes[] = "processDataYampi";
  558.             $ignoreRoutes[] = "processDataYampiBar";
  559.             $ignoreRoutes[] = "processDataCartPanda";
  560.             $ignoreRoutes[] = "processDataCartPandaBar";
  561.             $ignoreRoutes[] = "processDataKirvano";
  562.             $ignoreRoutes[] = "processDataKirvanoBar";
  563.             $ignoreRoutes[] = "callbackRdStation";
  564.             $ignoreRoutes[] = "callbackRdStationBar";
  565.             $ignoreRoutes[] = "callbackBling";
  566.             $ignoreRoutes[] = "callbackBlingBar";
  567.             $ignoreRoutes[] = "callbackDinamize";
  568.             $ignoreRoutes[] = "callbackDinamizeBar";
  569.             $ignoreRoutes[] = "certificateSearchPage";
  570.             $ignoreRoutes[] = "certificatePage";
  571.             $ignoreRoutes[] = "stopNotification";
  572.             $ignoreRoutes[] = "updateUserNotification";
  573.             $ignoreRoutes[] = "sendAuthenticationEmail";
  574.         }
  575.         if(in_array($request->get('_route'), $ignoreRoutes)){
  576.             return;
  577.         }
  578.         $url $this->generalService->generateUrl('home');
  579.         $redirectResponse = new RedirectResponse($url);
  580.         $redirectResponse->headers->set('Content-Type''text/html');
  581.         $redirectResponse->send();
  582.         exit;
  583.     }
  584.     public function checkUserIsComplete(Request $request)
  585.     {
  586.         if($this->user){
  587.             $userRepository $this->em->getRepository(User::class);
  588.             if(!$userRepository->checkUserIsComplete($this->user)){
  589.                 $ignoreRoutes = [
  590.                     "genereateAdminSSO",
  591.                     "loginEadminSSO",
  592.                     "sendCron",
  593.                     "userProfile",
  594.                     "updateLive",
  595.                     "meetRecordRegister",
  596.                     "logoff",
  597.                     "userLogoff",
  598.                     "getChargePage",
  599.                     "getCartItemsMenu",
  600.                     "cartInitiateCheckout",
  601.                     "checkoutOldCart",
  602.                     "checkoutNewCart",
  603.                     "checkoutCartWithCoupon",
  604.                     "checkoutClean",
  605.                     "cartIndividual",
  606.                     "cartAdd",
  607.                     "cartAddSuggestion",
  608.                     "cartCreateEnroll",
  609.                     "cartCheckoutPlanTrial",
  610.                     "addProductWhishlist",
  611.                     "applyCartCoupon",
  612.                     "cart",
  613.                     "getUserValidCarts",
  614.                     "cartChangeStatus",
  615.                     "cartCheckoutPaypal",
  616.                     "cartCheckoutPagseguro",
  617.                     "cartCheckoutMercadopago",
  618.                     "cartCheckoutCharge",
  619.                     "cartCheckoutDefault",
  620.                     "cartCheckoutCustom",
  621.                     "cartOneClickBuy",
  622.                     "cartCheckoutNewTry",
  623.                     "cartConclusion",
  624.                     "cartConclusionCheckStatus",
  625.                     "cartCouponRemove",
  626.                     "cartDelete",
  627.                     "countProductCouponByProductOffers",
  628.                     "listCouponByProductOffers",
  629.                     "testGeoSelectCep",
  630.                     "loginConfirm",
  631.                     "stopNotification",
  632.                     "updateUserNotification",
  633.                     "fileGetUpload",
  634.                     "getClientInfo",
  635.                     "downgradeToFree",
  636.                     "upgradeReceivers",
  637.                     "removeClientCustomDomain",
  638.                     "getInfo",
  639.                     "getInfoCourse"
  640.                 ];
  641.                 if(!in_array($request->get('_route'), $ignoreRoutes)){
  642.                     $url $this->generalService->generateUrl('userProfile');
  643.                     $redirectResponse = new RedirectResponse($url);
  644.                     $redirectResponse->headers->set('Content-Type''text/html');
  645.                     $redirectResponse->send();
  646.                     exit;
  647.                 }
  648.             }
  649.         }
  650.     }
  651.     public function checkUserSession(Request $request)
  652.     {
  653.         if(!$this->user){
  654.             $hash base64_encode($request->getUri());
  655.             $url $this->generalService->generateUrl('login', [ "hash" => $hash ]);
  656.             $redirectResponse = new RedirectResponse($url);
  657.             $redirectResponse->headers->set('Content-Type''text/html');
  658.             $redirectResponse->send();
  659.             exit;
  660.         }
  661.     }
  662.     public function jsonSerializer($arraySerilize) {
  663.         $encoders = [new JsonEncoder()];
  664.         $normalizers = [new ObjectNormalizer()];
  665.         $serializer = new Serializer($normalizers$encoders);
  666.         return $serializer->serialize($arraySerilize'json', [
  667.             'circular_reference_handler' => function ($object) {
  668.                 return $object->getId();
  669.             }
  670.         ]);
  671.     }
  672.     public function renderEAD($templateName$module "website")
  673.     {
  674.         //$this->data = $this->stringUtil->convertToUtf8($this->data);
  675.     
  676.         $pixelService $this->generalService->getService('Marketing\\PixelService');
  677.         $pixelService->sendConversion('PageView');
  678.          $this->data['nonceHash'] = bin2hex(random_bytes(16));
  679.         $allowSrc = [
  680.             "https://fonts.googleapis.com",
  681.             "https://cdnjs.cloudflare.com",
  682.             "https://cdn.eadplataforma.app",
  683.             "https://kit.fontawesome.com",
  684.             "https://www.googletagmanager.com",
  685.             "https://cdn.tailwindcss.com",
  686.             "https://player.sambatech.com.br",
  687.             "http://player.sambatech.com.br",
  688.             "https://player.pandavideo.com.br",
  689.             "https://fonts.gstatic.com",
  690.             "https://static.hotjar.com",
  691.             "https://player.vdocipher.com",
  692.             "https://www.google.com",
  693.             "http://testeeadpublic.s3.us-east-2.amazonaws.com",
  694.             "wss://metrics.eadplataforma.app",
  695.             "https://metrics.eadplataforma.app",
  696.             "https://www.google-analytics.com",
  697.             "https://analytics.google.com",
  698.             "http://livestream.com",
  699.             "'nonce-{$this->data['nonceHash']}'"
  700.         ];
  701.         $allowSrc implode(' '$allowSrc);
  702.         $optionsSrc = [
  703.             "default-src 'self'",
  704.             "script-src 'self' {$allowSrc}",
  705.             "object-src 'none'",
  706.             "style-src 'self' {$allowSrc}",
  707.             "font-src 'self' {$allowSrc}",
  708.             "img-src 'self' data: {$allowSrc}",
  709.             "connect-src 'self' {$allowSrc}",
  710.             "media-src 'self' {$allowSrc}",
  711.             "frame-src 'self' {$allowSrc}",
  712.             "report-uri /report/csp",
  713.         ];
  714.         $optionsSrc implode('; '$optionsSrc);
  715.             
  716.         $response $this->render("{$module}/{$templateName}"$this->data);
  717.         
  718.         //$response->headers->set("Content-Security-Policy", $optionsSrc);
  719.         return $response;
  720.     }
  721.     
  722.     public function eadResponse($data, ?int $errorCode ErrorEnum::SUCCESS,
  723.                                 ?bool $serializer true, ?bool $useHttpStatus false){
  724.         $response = [ "data" => $data"error" => !empty($errorCode) ? $errorCode false ];
  725.         
  726.         //$response = $this->stringUtil->convertToUtf8($response);
  727.         if($serializer){
  728.             $response $this->jsonSerializer($response);
  729.         }else{
  730.             $response json_encode($response);
  731.         }
  732.         $httpStatus 200;
  733.         if($useHttpStatus && $errorCode && isset(ErrorEnum::HTTP_STATUS[$errorCode])){
  734.             $httpStatus ErrorEnum::HTTP_STATUS[$errorCode];
  735.         }
  736.         return new JsonResponse($response$httpStatus, [], true);
  737.     }
  738.     public function validateEntity($entityObj$groups = []){
  739.         return $this->entityUtil->setEntity($entityObj)->validateEntity($groups);
  740.     }
  741.     public function createCaptchaKey(Request $request)
  742.     {
  743.         $preKey md5("captcha");
  744.         $value md5($this->client->getDomainPrimary().date('Y-m-d H:i:s').$request->getClientIp());
  745.         $key "{$preKey}_{$value}";
  746.         $data $this->stringUtil->randomText(6);
  747.         $this->memcacheService->saveData($key$data60 60 24);
  748.         return $key;
  749.     }
  750.     public function isValidCaptcha(Request $request)
  751.     {
  752.         $this->requestUtil->setRequest($request)->setData();
  753.         $gRecaptchaResponse $this->requestUtil->getField('g-recaptcha-response');
  754.         $eCaptchaPost $this->requestUtil->getField('e-captcha');
  755.         $keyCaptcha $this->requestUtil->getField('keyCaptcha');
  756.         $gSecretKey $this->configuration->get('recaptcha_secret_v2');
  757.         $gSecretKeyV3 $this->configuration->get('recaptcha_secret_v3');
  758.         $configDefault $this->configuration->getDefaultRecaptcha();
  759.         $host $request->getHost();
  760.         if(
  761.             !empty($gSecretKey) || 
  762.             !empty($gSecretKeyV3) || 
  763.             stristr($host".eadplataforma.app")
  764.         ){
  765.             if(!empty($gRecaptchaResponse)){
  766.                 $ip $request->getClientIp();
  767.                 $secret $configDefault->defaultRecaptchaSecretV3;
  768.                 if(!stristr($host".eadplataforma.app")){
  769.                     if(!empty($gSecretKeyV3)){
  770.                         $secret $gSecretKeyV3;
  771.                     }else if(!empty($gSecretKey)){
  772.                         $secret $gSecretKey;
  773.                     }
  774.                 }
  775.                 $dataUrl = [
  776.                     "secret" => $secret,
  777.                     "response" => $gRecaptchaResponse,
  778.                     "remoteip" => $ip,
  779.                 ];
  780.                 $dataUrl http_build_query($dataUrl);
  781.                 $url "https://www.google.com/recaptcha/api/siteverify?{$dataUrl}";
  782.                 $return file_get_contents($url);
  783.                 $return json_decode($return);
  784.                 if(!$return->success){
  785.                     return false;
  786.                 }
  787.                 if(isset($return->score)){
  788.                     if($return->score <= 0.7){
  789.                         return false;
  790.                     }
  791.                     return true;
  792.                 }
  793.                 return false;
  794.             }
  795.             return false;
  796.         }
  797.         return true;
  798.         
  799.         if(!empty($this->memcacheService->getData($keyCaptcha))){
  800.             return ($eCaptchaPost == $this->memcacheService->getData($keyCaptcha));
  801.         }else{
  802.             $this->memcacheService->deleteData($keyCaptcha);
  803.         }
  804.         return false;
  805.     }
  806. }