src/Controller/SecurityController.php line 166

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Suggestion;
  4. use App\Entity\User;
  5. use App\Entity\BioAuth;
  6. use App\Entity\BioAuthHistory;
  7. use App\Form\UserType;
  8. use App\Form\SuggestionType;
  9. use App\Repository\UserRepository;
  10. use App\Repository\BioAuthRepository;
  11. use App\Repository\ApplicationRepository;
  12. use App\Repository\BioAuthHistoryRepository
  13. use App\Repository\CheckQrRepository;
  14. use App\Repository\SuggestionRepository;
  15. use Symfony\Component\HttpFoundation\JsonResponse;
  16. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  17. use Symfony\Component\HttpFoundation\Response;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use Symfony\Component\Routing\Annotation\Route;
  20. use Symfony\Component\Filesystem\Filesystem;
  21. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  22. use Google\Auth\Credentials\ServiceAccountCredentials;
  23. Use Google\Auth\HttpHandler\HttpHandlerFactory;
  24. class SecurityController extends AbstractController
  25. {
  26.     /**
  27.      * @Route("/login", name="app_login")
  28.      */
  29.     public function index(Request $requestAuthenticationUtils $authenticationUtilsUserRepository $userRepo): Response
  30.     {
  31.         $login $request->get('_username');
  32.         $pass $request->get('_password');
  33.         $msg "";
  34.         if($login)
  35.         {        
  36.             $usr $userRepo->findOneBy(['username'=>$login]);
  37.             if(!empty($usr))
  38.             {
  39.                 if (password_verify($pass$usr->getPassword())) 
  40.                 {
  41.                     $session $request->getSession();
  42.                     $session->set('usrLogin'$usr->getUsername());
  43.                     $session->set('usrFirstName'$usr->getFirstName());
  44.                     $session->set('usrSurName'$usr->getSurName());
  45.                     $session->set('usrFullName'$usr->getSurName()." ".$usr->getFirstName());
  46.                     $session->set('usrPhone'$usr->getPhone());
  47.                     $session->set('usrEmail'$usr->getEmail());
  48.                     $session->set('usrOrganization'$usr->getOrganization());
  49.                     //$session->set('usrIsBioAuth', $usr->getIsBioAuth());
  50.                     
  51.                     if($usr->getIsBioAuth()==2)//Pending bio verification
  52.                     {
  53.                         return $this->redirectToRoute('dashboard_double_auth_verification');
  54.                     }    
  55.                     if($usr->getIsBioAuth()==or $usr->getIsBioAuth() == null)//Pending bio subscription
  56.                     {
  57.                         return $this->redirectToRoute('dashboard_double_auth_subscription');
  58.                     }
  59.                     return $this->redirectToRoute('dashboard_double_auth_verification');
  60.                     
  61.                 }else{
  62.                     $msg "Wrong password...";
  63.                 }
  64.             }else{
  65.                 $msg "Wrong login...";
  66.             }
  67.         }
  68.         if($msg)
  69.         {
  70.             $this->get('session')->getFlashBag()->add('danger'$msg);                    
  71.         }
  72.         // get the login error if there is one
  73.          $error $authenticationUtils->getLastAuthenticationError();
  74.          // last username entered by the user
  75.          $lastUsername $authenticationUtils->getLastUsername();
  76.         //dump($authenticationUtils);
  77.           return $this->render('security/index.html.twig', [
  78.              'controller_name' => 'LoginController',
  79.              'last_username' => $lastUsername,
  80.              'error'         => $error,
  81.              'msg'         => $msg,
  82.           ]);
  83.         /*  
  84.         return $this->render('security/index.html.twig', [
  85.             'controller_name' => 'SecurityController',
  86.         ]);
  87.         */
  88.     }
  89.    
  90.     /**
  91.      * @Route("/home", name="app_home")
  92.      */
  93.     public function homePage(Request $requestSuggestionRepository $suggestionRepoUserRepository $userRepo): Response
  94.     {
  95.         $session $request->getSession();
  96.         $login $session->get('usrLogin');
  97.         $suggestion = new Suggestion();
  98.         $form $this->createForm(SuggestionType::class, $suggestion);
  99.         $form->handleRequest($request);
  100.         if($login)
  101.         {
  102.             $usr $userRepo->findOneBy(['username'=>$login]);
  103.             if(!empty($usr))
  104.             {
  105.                 
  106.                     $session $request->getSession();
  107.                     $session->set('usrLogin'$usr->getUsername());
  108.                     $session->set('usrFirstName'$usr->getFirstName());
  109.                     $session->set('usrFullName'$usr->getSurName()." ".$usr->getFirstName());
  110.                     $session->set('usrSurName'$usr->getSurName());
  111.                     $session->set('usrPhone'$usr->getPhone());
  112.                     $session->set('usrEmail'$usr->getEmail());
  113.                     $session->set('usrOrganization'$usr->getOrganization());
  114.                     //$session->set('usrIsBioAuth', $usr->getIsBioAuth());
  115.                     
  116.                     if($usr->getIsBioAuth()==2)//Pending bio verification
  117.                     {
  118.                         return $this->redirectToRoute('dashboard_double_auth_verification');
  119.                     }    
  120.                     if($usr->getIsBioAuth()==or $usr->getIsBioAuth() == null)//Pending bio subscription
  121.                     {
  122.                         return $this->redirectToRoute('dashboard_double_auth_subscription');
  123.                     }
  124.                     if ($form->isSubmitted() && $form->isValid()) 
  125.                     {
  126.                         $suggestion->setUser($usr);
  127.                         $suggestionRepository->add($suggestiontrue);
  128.                         $this->get('session')->getFlashBag()->add('success'"Succesfully saved..."); 
  129.                 
  130.                         //return $this->redirectToRoute('app_suggestion_index', [], Response::HTTP_SEE_OTHER);
  131.                     }
  132.             }else
  133.             {
  134.                 $this->get('session')->getFlashBag()->add('danger'"An error occurred during the operation, try again..."); 
  135.                 return $this->redirectToRoute('app_login');
  136.             }
  137.         }else
  138.         {    
  139.             $this->get('session')->getFlashBag()->add('danger'"Your session has expired, log in..."); 
  140.             return $this->redirectToRoute('app_login');
  141.         }
  142.         
  143.         return $this->renderForm('security/home.html.twig'
  144.         [
  145.             'userName' => $session->get('usrFullName'),
  146.             'suggestion' => $suggestion,
  147.             'form' => $form,
  148.         ]);
  149.     }
  150.     /**
  151.      * @Route("/enroll", name="app_enroll")
  152.      */
  153.     public function enroll(Request $requestUserRepository $userRepo): Response
  154.     {   
  155.         $user = new User();
  156.         $form $this->createForm(UserType::class, $user);
  157.         $form->handleRequest($request);
  158.         if ($form->isSubmitted() && $form->isValid()) 
  159.         {
  160.             $userRepo->add($usertrue);
  161.             $this->get('session')->getFlashBag()->add('success'"Your account has been successfully created...");
  162.                     
  163.             return $this->redirectToRoute('app_login', [], Response::HTTP_SEE_OTHER);
  164.         }
  165.         return $this->renderForm('security/enroll.html.twig', [
  166.             'user' => $user,
  167.             'form' => $form,
  168.         ]);
  169.         
  170.     }
  171.     
  172.     /**
  173.      * Subscribe IDO to an account for Bio validation OK
  174.      *
  175.      * @Route("/double/auth/subscription", name="dashboard_double_auth_subscription", methods={"GET", "POST"})
  176.      * 
  177.      */
  178.     public function doubleAuthSubscriptionAction(Request $requestBioAuthRepository $bioAuthRepository,  CheckQrRepository $checkQrRepository,  ApplicationRepository $applicationRepositoryUserRepository $userRepo): Response
  179.     {
  180.         $session $request->getSession();
  181.         $lgin $session->get('usrLogin');
  182.         $fullName $session->get('usrFullName');
  183.         
  184.        // $session->set('usrFullName', $usr->getUsername()." ".$usr->getFirstName());
  185.         if($_POST)
  186.         {
  187.             $action $request->get("action");
  188.             if($action=="preenroler")
  189.             {
  190.                 $civilite $request->get("civilite");
  191.                 $nom $request->get("nom");
  192.                 $prenom $request->get("prenom");
  193.                 $dateNaissance $request->get("dateNaissance");
  194.                 $lieuNaissance $request->get("lieuNaissance");
  195.                 $nationalite $request->get("nationalite");
  196.                 $numeroTelephone $request->get("numeroTelephone");
  197.                 $adresseEmail $request->get("adresseEmail");
  198.                 
  199.                 $curl curl_init();
  200.                 curl_setopt_array($curl, array(
  201.                         CURLOPT_URL => $this->getParameter('kyvala_host').'/person/pre/enrolement/new/json',
  202.                         CURLOPT_RETURNTRANSFER => true,
  203.                         CURLOPT_ENCODING => '',
  204.                         CURLOPT_MAXREDIRS => 10,
  205.                         CURLOPT_TIMEOUT => 0,
  206.                         CURLOPT_FOLLOWLOCATION => true,
  207.                         CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  208.                         CURLOPT_CUSTOMREQUEST => 'POST',
  209.                         CURLOPT_POSTFIELDS => array('civilite' => 'Mme/Mr','nom' => $nom,'prenom' =>$prenom,'dateNaissance' => $dateNaissance,'lieuNaissance' => $lieuNaissance ,'nationalite' => $nationalite,'numeroTelephone' => $numeroTelephone,'adresseEmail' => $adresseEmail ),
  210.                 ));
  211.                 $response curl_exec($curl);
  212.                 $response json_decode($response,true);
  213.                 curl_close($curl);
  214.                 
  215.                 if($response['Etat']=="SUCCESS")
  216.                 {
  217.                     return $this->render('security/kyvala-subscription.html.twig', array(
  218.                         'isModal'=>3,// pour le préenrolement succes
  219.                         'message'=>$response['Message'],
  220.                         'reference'=>$response['sqr'],
  221.                         'statut'=>$response['Etat']
  222.                     ));  
  223.                 }else
  224.                 {
  225.                     // erreur de traitement
  226.                     $this->get('session')->getFlashBag()->add('warning'"An error occurred while saving. Please try again...");
  227.                     
  228.                 }
  229.             }elseif($action=="souscrire")
  230.             {
  231.                 $ref1 $request->get("ref1");
  232.                 $ref2 $request->get("ref2");
  233.                 $ref3 $request->get("ref3");
  234.                 $reference $ref1."-"$ref2."-"$ref3;
  235.                 $identifiant $session->get('usrLogin');;
  236.                 $appKey $this->getParameter('token_key');
  237.                 if (!empty($identifiant) && !empty($reference) && !empty($appKey)) 
  238.                 {
  239.                     $application $applicationRepository->findOneBy(['applicationPass'=>$appKey]);
  240.                     if($application)
  241.                     {
  242.                         $checkQr $checkQrRepository->findOneBy(['numero'=>$reference]);
  243.                         //$person = $personRepository->findOneBySqr($reference);
  244.                         if($checkQr)
  245.                         {
  246.                             $userToActivate $bioAuthRepository->findOneBy(['application'=>$application'identification'=>$identifiant]);
  247.                             if(!$userToActivate)
  248.                             {
  249.                                 $bioAuth = new BioAuth();
  250.                                 
  251.                                 $bioAuth->setIdentification($identifiant);
  252.                                 $bioAuth->SetUserReference($checkQr);
  253.                                 $bioAuth->setApplication($application);
  254.                                 
  255.                                 $bioAuthRepository->add($bioAuthfalse);
  256.                                 /*
  257.                                 $return = array(
  258.                                     'Etat' => 'SUCCESS',
  259.                                     'Message' => "Double authentification configurée avec succès sur ce compte...",
  260.                                     'civility'=>$checkQr->getPersonCivil()[0]->getCivility(),
  261.                                     'firstName'=>$checkQr->getPersonCivil()[0]->getFirstName(),
  262.                                     'lastName'=>$checkQr->getPersonCivil()[0]->getLastName(),
  263.                                     'selfie_link'=>"uploads/kyvala/enrolment/".$checkQr->getPersonBiometrics()[0]->getFace(),
  264.                                     //'sqr'=>$person->getCheckQr()->getNumero(),
  265.                                     //'hash'=>$person->getCheckQr()->getLibelle(),
  266.                                     //'transactionId'=>$person->getEnrolmentId(),
  267.                                     //'transactionUid'=>$person->getEnrolmentUid(),
  268.                                 );
  269.                                 */
  270.                                 
  271.                                 $acc $userRepo->findOneby(["username"=>$identifiant]);
  272.                                 $acc->setIsBioAuth(1);//activation de la double auth                                    
  273.                                 $userRepo->add($acctrue);
  274.                                 return $this->render('security/kyvala-subscription.html.twig', array(
  275.                                     'isModal'=>2,// pour la souscription directe
  276.                                     'message'=>"Biometric authentication successfully configured on this account...",
  277.                                     'referece'=>$reference,
  278.                                     'statut'=>'SUCCESS',
  279.                                     'nom'=>$checkQr->getPersonCivil()[0]->fullName(),
  280.                                     'loginUser'=>$lgin,
  281.                                     'selfie_link'=>"uploads/kyvala/enrolment/".$checkQr->getPersonBiometrics()[0]->getFace(),
  282.                                 ));   
  283.                             }else
  284.                             {
  285.                                 $this->get('session')->getFlashBag()->add('warning'"Unable to continue processing. Two-factor authentication for this account is already enabled....");
  286.                             }
  287.                             
  288.                         }else
  289.                         {
  290.                             $this->get('session')->getFlashBag()->add('warning'"This IDO is not associated with any enrolled individual. Please check and try again...");
  291.                         }
  292.                     }else
  293.                     {
  294.                         $this->get('session')->getFlashBag()->add('warning'"You do not have permission for this request...");
  295.                     }
  296.                 }else
  297.                 {
  298.                     $this->get('session')->getFlashBag()->add('warning'"Missing required parameters...");
  299.                 }
  300.             }
  301.         }
  302.         return $this->render('security/kyvala-subscription.html.twig', array(
  303.             'isModal'=>1,
  304.             'loginUser'=>$lgin,
  305.             'fullName'=>$fullName
  306.         ));
  307.     }
  308.     
  309.     /**
  310.      * Initier une transaction de double véritifation sur Kyvala Poc OK
  311.      *
  312.      * @Route("/double/auth/verification", name="dashboard_double_auth_verification", methods ={"GET", "POST"})
  313.      * 
  314.      */
  315.     public function doubleAuthVerificationAction(Request $requestBioAuthHistoryRepository $bioAuthHistoryRepositoryBioAuthRepository $bioAuthRepositoryApplicationRepository $applicationRepository,  CheckQrRepository $checkQrRepository): Response
  316.     {
  317.         
  318.         $session $request->getSession();
  319.         //Get sqr and image link
  320.         $curl curl_init();
  321.         curl_setopt_array($curl, array(
  322.             CURLOPT_URL => 'https://checktatoo.com/fr/notification/generate/qr/sqr/token',
  323.             CURLOPT_RETURNTRANSFER => true,
  324.             CURLOPT_ENCODING => '',
  325.             CURLOPT_MAXREDIRS => 10,
  326.             CURLOPT_TIMEOUT => 0,
  327.             CURLOPT_FOLLOWLOCATION => true,
  328.             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  329.             CURLOPT_CUSTOMREQUEST => 'GET',
  330.         ));
  331.         $response curl_exec($curl);
  332.         $response json_decode($response,true);
  333.         curl_close($curl);
  334.         //dump($response);
  335.         if($response['Etat']=="SUCCESS")
  336.         {
  337.             /*
  338.             {
  339.                 "Etat": "SUCCESS",
  340.                 "Message": "Le qr a été généré avec succès...",
  341.                 "step": "process",
  342.                 "hash": "1BDKqdWcWw1yXPSVDadPB9Q==",
  343.                 "ref": "6159-6416-5827",
  344.                 "qrCode": "checktatoo.com/qrcode/token_authentification_qr_2024090306593077.png"
  345.             }
  346.             */
  347.             
  348.             $identifiant =  $session->get('usrLogin');// app unique identifier
  349.             $authReference $response['ref'];//project transaction reference
  350.             $appKey $this->getParameter('token_key');// project unique key
  351.             if (!empty($identifiant) && !empty($authReference) && !empty($appKey)) 
  352.             {
  353.                 $application $applicationRepository->findOneBy(['applicationPass'=>$appKey]);
  354.                 if($application)
  355.                 {
  356.                     $bioAuth $bioAuthRepository->findOneBy(['application'=>$application'identification'=>$identifiant]);
  357.                     if($bioAuth)
  358.                     {                                               
  359.                         try 
  360.                         {
  361.                             
  362.                             //Buffering the output
  363.                             ob_start();  
  364.                             
  365.                             //Getting configuration details 
  366.                             system('ipconfig /all');  
  367.                             
  368.                             //Storing output in a variable 
  369.                             $configdata=ob_get_contents();  
  370.                             
  371.                             // Clear the buffer  
  372.                             ob_clean();  
  373.                             
  374.                             //Extract only the physical address or Mac address from the output
  375.                             $mac "Adresse physique";  
  376.                             //$mac = "Physical";  
  377.                             $pmac strpos($configdata$mac);
  378.                             
  379.                             // Get Physical Address  
  380.                             $macaddr=substr($configdata,($pmac+41),17);  
  381.                             //$macaddr=substr($configdata,($pmac+36),17); 
  382.                             
  383.                             $bioAuthHistory = new BioAuthHistory();
  384.                             $bioAuthHistory->setTransactionReference($authReference);
  385.                             $bioAuthHistory->setBioAuth($bioAuth);
  386.                             
  387.                             // get client infos
  388.                             $bioAuthHistory->setHttpRemoteIp(htmlspecialchars($request->server->get('HTTP_REMOTE_IP')));
  389.                             $bioAuthHistory->setRemotePort(htmlspecialchars($request->server->get('REMOTE_PORT')));
  390.                             $bioAuthHistory->setRemoteAdress(htmlspecialchars($request->server->get('REMOTE_ADDR')));
  391.                             $bioAuthHistory->setHttpUserAgent(htmlspecialchars($request->server->get('HTTP_USER_AGENT')));
  392.                             $bioAuthHistory->setGeoipLongitude(htmlspecialchars($request->server->get('GEOIP_LONGITUDE')));
  393.                             $bioAuthHistory->setGeoipLatitude(htmlspecialchars($request->server->get('GEOIP_LATITUDE')));
  394.                             $bioAuthHistory->setGeoipAreaCode(htmlspecialchars($request->server->get('GEOIP_AREA_CODE')));
  395.                             $bioAuthHistory->setGeoipDmaCode(htmlspecialchars($request->server->get('GEOIP_DMA_CODE')));
  396.                             $bioAuthHistory->setGeoipCity(htmlspecialchars($request->server->get('GEOIP_CITY')));
  397.                             $bioAuthHistory->setGeoipRegion(htmlspecialchars($request->server->get('GEOIP_REGION')));
  398.                             $bioAuthHistory->setGeoipCountryName(htmlspecialchars($request->server->get('GEOIP_COUNTRY_NAME')));
  399.                             $bioAuthHistory->setGeoipCountryCode(htmlspecialchars($request->server->get('GEOIP_COUNTRY_CODE')));
  400.                             $bioAuthHistory->setUniqueId(htmlspecialchars($request->server->get('UNIQUE_ID')));
  401.                             $bioAuthHistory->setMac(htmlspecialchars($macaddr));                          
  402.                             
  403.                             //Send notification to Firebase
  404.                             //if(!empty($bioAuthHistory->getBioAuth()->getUserReference()->getPersoncivil()[0]->getFirebaseToken()))
  405.                             if(!empty($bioAuthHistory->getBioAuth()->getUserReference()->getPersonAppIdentitiesUserReference()[0]->getToken()))
  406.                             {
  407.                                 $this->ParamsWithSendPushNotification($bioAuthHistory->getBioAuth()->getUserReference()->getPersonAppIdentitiesUserReference()[0]->getToken(),"Authentication request!!! ",$bioAuthHistory->getTransactionReference().": ".$bioAuthHistory->getBioAuth()->getUserReference()->getPersoncivil()[0]->fullName().", Please confirm that you wish to access your account in the space "$bioAuthHistory->getBioAuth()->getApplication()->getName(). " from a device with the ip address : "$bioAuthHistory->getHttpRemoteIp() ." on the ".date("d-m-Y H:i:s")." or report if it's not you.");
  408.                                 $this->ParamsWithSendPushNotification($bioAuthHistory->getBioAuth()->getUserReference()->getPersonAppIdentitiesUserReference()[0]->getToken(),"Demande d'authentification !!! ",$bioAuthHistory->getTransactionReference().": ".$bioAuthHistory->getBioAuth()->getUserReference()->getPersoncivil()[0]->fullName().", Merci de confirmer que vous souhaitez acceder à votre compte dans l'espace "$bioAuthHistory->getBioAuth()->getApplication()->getName(). " à partir d'un périphérique ayant l'adresse ip : "$bioAuthHistory->getHttpRemoteIp() ." le ".date("d-m-Y H:i:s")." ou signalez s'il ne s'agit pas de vous.");
  409.                             }
  410.                             
  411.                             $bioAuthHistoryRepository->add($bioAuthHistorytrue);
  412.                             
  413.                             return $this->render('security/kyvala-verification.html.twig', array(
  414.                                 'Message' => "Request for biometric authentication successfully registered...",
  415.                                 'nom'=>$bioAuthHistory->getBioAuth()->getUserReference()->getPersonCivil()[0]->fullName(),
  416.                                 'selfie_link'=>"uploads/kyvala/enrolment/".$bioAuthHistory->getBioAuth()->getUserReference()->getPersonBiometrics()[0]->getFace(),
  417.                                 'Etat' => 'SUCCESS',
  418.                                 'step'=>'process',
  419.                                 'ref'=>$response['ref'],
  420.                                 'stop'=>'1',
  421.                                 'qrCode'=>$response['qrCode'],
  422.                                 'key'=>$this->getParameter('token_key')
  423.                             ));
  424.                         } catch (\Throwable $error
  425.                         {
  426.                             //not actions
  427.                             $fs = new Filesystem();
  428.                             //$fs->appendToFile('EventLogFiles.txt', "\r\n ".json_encode($error));
  429.                             $fs->appendToFile('EventLogFiles.txt'"\r\n ".$error);
  430.                             /*$return = array(
  431.                                 'Etat' =>'FAILED' , 
  432.                                 'Message' =>"Une erreur est survenue lors de l'opération. Veuillez essayer ultérieurement SVP", 
  433.                                 'error'=>json_encode($error),
  434.                             );*/
  435.                             $this->get('session')->getFlashBag()->add('warning'"An error occurred during the operation. Please try later...");
  436.                             return $this->redirectToRoute('app_login');
  437.                         }
  438.                         
  439.                     }else
  440.                     {
  441.                         $this->get('session')->getFlashBag()->add('warning'"Biometric authentication has not yet been configured on this account. Please follow the following steps to activate the service on your account...");
  442.                         return $this->redirectToRoute('app_login');
  443.                     }
  444.                 }else
  445.                 {
  446.                     $this->get('session')->getFlashBag()->add('warning'"You do not have permission for this request...");
  447.                     return $this->redirectToRoute('app_login');                    
  448.                 }
  449.             }else
  450.             {
  451.                 $this->get('session')->getFlashBag()->add('warning'"Missing required parameters...");
  452.                 return $this->redirectToRoute('app_login');                    
  453.             }
  454.             
  455.         }elseif($response['Etat']=="FAILED")
  456.         {
  457.             $this->get('session')->getFlashBag()->add('warning'"Unable to reach the partner's server, try again...");
  458.             return $this->redirectToRoute('app_login');
  459.         }
  460.     }
  461.     
  462.     /**
  463.      * Check Status of an existing authentification OK
  464.      *
  465.      * @Route("/check/auth/status", name="dashboard_check_auth_status", methods={"GET", "POST"})
  466.      * 
  467.      */
  468.     public function checkAuthStatusAction(Request $requestBioAuthHistoryRepository $bioAuthHistoryRepositoryApplicationRepository $applicationRepositoryUserRepository $userRepo): Response
  469.     {
  470.         //$em = $this->getDoctrine()->getManager(); 
  471.         //$reference = $request->get('authReference');
  472.         //$appKey = $this->getParameter('token_key');
  473.         $authReference $request->get("authReference");//project transaction reference
  474.         $appKey $this->getParameter('token_key');// project unique key
  475.             if (!empty($authReference) && !empty($appKey)) 
  476.             {
  477.                 $application $applicationRepository->findOneBy(['applicationPass'=>$appKey]);
  478.                 if($application)
  479.                 {
  480.                     $bioAuthHistory $bioAuthHistoryRepository->findOneBy(['transactionReference'=>$authReference]);
  481.                     if($bioAuthHistory)
  482.                     {
  483.                         /*
  484.                         $return = array(
  485.                             'Etat' => 'SUCCESS',
  486.                             'Message' => "Enregistrement recupérée avec succès...",
  487.                             'authentication_status' => $bioAuthHistory->getUserAccess(),
  488.                             'transaction_reference' => $bioAuthHistory->getTransactionReference(),
  489.                             //'nom'=>$bioAuthHistory->getBioAuth()->getPerson()->fullName(),
  490.                             //'sqr'=>$bioAuthHistory->getBioAuth()->getPerson()->getCheckQr()->getNumero(),
  491.                             //'hash'=>$bioAuthHistory->getBioAuth()->getPerson()->getCheckQr()->getLibelle(),
  492.                             //'transactionId'=>$bioAuthHistory->getBioAuth()->getPerson()->getEnrolmentId(),
  493.                             //'transactionUid'=>$bioAuthHistory->getBioAuth()->getPerson()->getEnrolmentUid(),
  494.                         );*/
  495.                         switch ($bioAuthHistory->getUserAccess())
  496.                         {
  497.                             case 'GRANTED':
  498.                                 # code...
  499.                                 $identifiant $bioAuthHistory->getBioAuth()->getIdentification();
  500.                                 $account $userRepo->findOneby(["username"=>$identifiant]);
  501.                                 $account->setIsBioAuth(1);// on met que le bio auth est ok.                                   
  502.                                 $userRepo->add($accounttrue);
  503.                                 
  504.                                 $this->get('session')->getFlashBag()->add('success'"Double authentication completed successfully. Welcome ".$account->fullName());
  505.                                 break;
  506.                             case 'REJECTED':
  507.                                 # code...
  508.                                 break;                
  509.                             case 'SIGNALED':
  510.                                 # code...
  511.                                 break;                
  512.                             default:
  513.                                 # code...
  514.                                 break;
  515.                         }
  516.                         $return = array(
  517.                             'Etat' =>'SUCCESS' 
  518.                             'Message' =>"Record successfully recovered..."
  519.                             'auth_status'=>$bioAuthHistory->getUserAccess()
  520.                         );
  521.                     }else
  522.                     {
  523.                         $return = array(
  524.                             'Etat' =>'FAILED' 
  525.                             'Message' =>"The reference is not associated with any pending transaction..."
  526.                         );
  527.                     }
  528.                 }else
  529.                 {
  530.                     $return = array(
  531.                         'Etat' =>'FAILED' 
  532.                         'Message' =>"You do not have permission for this request..."
  533.                     );
  534.                 }
  535.             }else
  536.             {
  537.                 $return = array(
  538.                     'Etat' =>'FAILED' 
  539.                     'Message' =>"Missing required parameters..."
  540.                 );
  541.             }
  542.         
  543.         return new JsonResponse($return);
  544.     }
  545.     //notifications push avec paramètres OK
  546.     public function ParamsWithSendPushNotification($user_notification_token,$title,$message)
  547.     {
  548.         //https://www.youtube.com/watch?v=YHniUsrmX9Y
  549.         $fs = new Filesystem();
  550.         $credential = new ServiceAccountCredentials(
  551.             "https://www.googleapis.com/auth/firebase.messaging",
  552.             json_decode(file_get_contents
  553.             ("kyvala-45525-firebase-adminsdk-cxpp5-cf78b66d72.json"),true)
  554.         );
  555.         $token $credential->fetchAuthToken(HttpHandlerFactory::build());
  556.         $accessToken $token['access_token'];
  557.         $ch curl_init("https://fcm.googleapis.com/v1/projects/kyvala-45525/messages:send");
  558.         curl_setopt($chCURLOPT_HTTPHEADER,[
  559.             'Content-Type: application/json',
  560.             'Authorization: ' 'Bearer ' .$accessToken
  561.         ]);
  562.         curl_setopt($chCURLOPT_POSTFIELDS'{
  563.             "message": {
  564.                 "token":"'.$user_notification_token.'",
  565.                 "notification": {
  566.                     "title":"'.$title.'",
  567.                     "body":"'.$message.'",
  568.                     "image":"http://poc.kyvala.com/uploads/TOKEN/Token-logo-avec-fond.png"
  569.                 }
  570.             }
  571.         }');
  572.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  573.         curl_setopt($chCURLOPT_VERBOSEtrue);
  574.         $response curl_exec($ch);
  575.         
  576.         if (curl_errno($ch)) 
  577.         {
  578.             print "Error: " curl_error($ch);
  579.             $fs->appendToFile('EventLogNotification.txt'"\r\n ".date("d-m-Y H:i:s")." : deviceToken :".$user_notification_token.", Title: ".$title.", Notification: ".$message.", Error:  ".json_encode(curl_error($ch)));
  580.             exit();
  581.         }else
  582.         {
  583.             $json json_decode($responsetrue);
  584.         }
  585.         // Show me the result
  586.         curl_close($ch);
  587.         //dump($season_data);
  588.         
  589.         $fs->appendToFile('EventLogNotification.txt'"\r\n ".date("d-m-Y H:i:s")." : DeviceToken :".$user_notification_token.", Title: ".$title.", Notification: ".$message.", Retours: ".json_encode($response));
  590.         // return a JSON object to caller
  591.         return $json;
  592.     }
  593. }