src/Controller/AuthenticationController.php line 17

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Log;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Symfony\Component\HttpFoundation\Session\Session;
  10. class AuthenticationController extends AbstractController
  11. {
  12.   #[Route('/authentication'name'app_authentication')]
  13.   public function login(Request $requestSession $sessionEntityManagerInterface $entityManager): Response
  14.   {
  15.     if ($request->request->count() > 0) {
  16.       $phone $request->request->get("phone");
  17.       $password $request->request->get("password");
  18.       $ch curl_init();
  19.       curl_setopt($chCURLOPT_URL"https://carenapi235679814.caren-niger.com/api/login");
  20.       curl_setopt($chCURLOPT_POST1);
  21.       curl_setopt($chCURLOPT_POSTFIELDS'{
  22.             "username" : "' $phone '",
  23.             "password" : "' $password '"
  24.           }');
  25.       $headers = array(
  26.         "Content-Type: application/json",
  27.         "Accept: application/json",
  28.       );
  29.       curl_setopt($chCURLOPT_HTTPHEADER$headers);
  30.       //for debug only!
  31.       curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
  32.       curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  33.       curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  34.       $server_output curl_exec($ch);
  35.       curl_close($ch);
  36.       $resp json_decode(preg_replace('/[\x00-\x1F\x80-\xFF]/'''$server_output), true);
  37.       // dd($resp);
  38.       if ($resp == null) {
  39.         $this->addFlash('NotifErrors'"Connexion avec l'api interrompu");
  40.         $iduser null;
  41.         $idclient null;
  42.         $action "Authentification";
  43.         $msg_send "Connexion";
  44.         $msg_get "Connexion avec l'api interrompu.";
  45.         $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  46.         $entityManager->persist($log);
  47.         $entityManager->flush();
  48.         return $this->redirectToRoute('app_authentication');
  49.       } else {
  50.         if ($resp['statut'] == 201) {
  51.           $error $session->get('message'$resp['message']);
  52.           $this->addFlash('NotifErrors'$resp['message']);
  53.         $iduser null;
  54.         $idclient null;
  55.         $action "Authentification";
  56.         $msg_send "Connexion";
  57.         $msg_get $resp['message'];
  58.         $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  59.         $entityManager->persist($log);
  60.         $entityManager->flush();
  61.           return $this->redirectToRoute('app_authentication');
  62.         } else {
  63.           if ($resp['statut'] == 400) {
  64.             $error $session->get('message'$resp['message']);
  65.             $this->addFlash('NotifErrors'$resp['message']);
  66.             $iduser null;
  67.             $idclient null;
  68.             $action "Authentification";
  69.             $msg_send "Connexion";
  70.             $msg_get $resp['message'];
  71.             $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  72.             $entityManager->persist($log);
  73.             $entityManager->flush();
  74.             return $this->redirectToRoute('app_authentication');
  75.           } else {
  76.             if ($resp['statut'] == 200) {
  77.               $session->start();
  78.               $iduser null;
  79.               $idclient null;
  80.               $action "Authentification";
  81.               $msg_send "Connexion";
  82.               $msg_get "Connexion reussie";
  83.               $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  84.               $entityManager->persist($log);
  85.               $entityManager->flush();
  86.               // set and get session attributes
  87.               $session->set('client'$resp['client']);
  88.               $session->set('token'$resp['token']);
  89.               $idClient $session->set('idClient'$resp['client']['id']);
  90.               return $this->redirectToRoute('app_assurance_auto');
  91.             }
  92.           }
  93.         }
  94.       }
  95.     }
  96.     return $this->render('authentication/login.html.twig', [
  97.       'messageErr' => '',
  98.     ]);
  99.   }
  100.   #[Route('/logout'name'app_logout')]
  101.   public function logout(EntityManagerInterface $emSession $session): Response
  102.   {
  103.     $session->clear();
  104.     return $this->redirectToRoute('app_home');
  105.   }
  106.   #[Route('/register'name'app_register')]
  107.   public function register(Request $requestSession $sessionEntityManagerInterface $entityManager,): Response
  108.   {
  109.     $ch curl_init();
  110.     curl_setopt($chCURLOPT_URL"https://carenapi235679814.caren-niger.com/api/client/typeClient");
  111.     $headers = array(
  112.       "Content-Type: application/json",
  113.       "Accept: application/json",
  114.     );
  115.     curl_setopt($chCURLOPT_HTTPHEADER$headers);
  116.     //for debug only!
  117.     curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
  118.     curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  119.     curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  120.     $server_output curl_exec($ch);
  121.     curl_close($ch);
  122.     $typeClients json_decode(preg_replace('/[\x00-\x1F\x80-\xFF]/'''$server_output), true);
  123.     if ($request->request->count() > 0) {
  124.       // $typeClient = $request->request->get("typeClient");
  125.       $nom $request->request->get("firstname");
  126.       $prenom $request->request->get("lastname");
  127.       $telephone $request->request->get("phone");
  128.       $motdepasse $request->request->get("motDePasse");
  129.       $motdepasse2 $request->request->get("motDePasse2");
  130.       $ch curl_init();
  131.       curl_setopt($chCURLOPT_URL"https://carenapi235679814.caren-niger.com/api/client");
  132.       curl_setopt($chCURLOPT_POST1);
  133.       curl_setopt($chCURLOPT_POSTFIELDS'{
  134.                 "nom" : "' $nom '",
  135.                 "prenom" : "' $prenom '",
  136.                 "telephone" : "' $telephone '",
  137.                 "password" : "' $motdepasse '",
  138.                 "password2" : "' $motdepasse2 '"
  139.             }');
  140.       $headers = array(
  141.         "Content-Type: application/json",
  142.         "Accept: application/json",
  143.       );
  144.       curl_setopt($chCURLOPT_HTTPHEADER$headers);
  145.       //for debug only!
  146.       curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
  147.       curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  148.       curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  149.       $server_output curl_exec($ch);
  150.       curl_close($ch);
  151.       $resp json_decode(preg_replace('/[\x00-\x1F\x80-\xFF]/'''$server_output), true);
  152.       if ($resp == null) {
  153.         $this->addFlash('message'"Connexion avec l'api interrompu");
  154.         $iduser null;
  155.         $idclient null;
  156.         $action "Creation compte client";
  157.         $msg_send "Creation";
  158.         $msg_get "Connexion avec l'api interrompu";
  159.         $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  160.         $entityManager->persist($log);
  161.         $entityManager->flush();
  162.         return $this->redirectToRoute('app_register');
  163.       } else {
  164.         if ($resp['statut'] == 400) {
  165.           $error $session->get('message'$resp['message']);
  166.           $this->addFlash('warning'$resp['message']);
  167.           $iduser null;
  168.           $idclient null;
  169.           $action "Creation compte client";
  170.           $msg_send "Creation";
  171.           $msg_get $resp['message'];
  172.           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  173.           $entityManager->persist($log);
  174.           $entityManager->flush();
  175.           return $this->redirectToRoute('app_register');
  176.         } else {
  177.           if ($resp['statut'] == 401) {
  178.             $error $session->get('message'$resp['message']);
  179.             $this->addFlash('warning'$resp['message']);
  180.             $iduser null;
  181.           $idclient null;
  182.           $action "Creation compte client";
  183.           $msg_send "Creation";
  184.           $msg_get $resp['message'];
  185.           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  186.           $entityManager->persist($log);
  187.           $entityManager->flush();
  188.             return $this->redirectToRoute('app_register');
  189.           } else {
  190.             if ($resp['statut'] == 402) {
  191.               $error $session->get('message'$resp['message']);
  192.               $this->addFlash('warning'$resp['message']);
  193.               $iduser null;
  194.           $idclient null;
  195.           $action "Creation compte client";
  196.           $msg_send "Creation";
  197.           $msg_get $resp['message'];
  198.           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  199.           $entityManager->persist($log);
  200.           $entityManager->flush();
  201.               return $this->redirectToRoute('app_register');
  202.             } else {
  203.               if ($resp['statut'] == 403) {
  204.                 $error $session->get('message'$resp['message']);
  205.                 $this->addFlash('warning'$resp['message']);
  206.                 $iduser null;
  207.           $idclient null;
  208.           $action "Creation compte client";
  209.           $msg_send "Creation";
  210.           $msg_get $resp['message'];
  211.           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  212.           $entityManager->persist($log);
  213.           $entityManager->flush();
  214.                 return $this->redirectToRoute('app_register');
  215.               } else {
  216.                 if ($resp['statut'] == 404) {
  217.                   $error $session->get('message'$resp['message']);
  218.                   $this->addFlash('warning'$resp['message']);
  219.                   $iduser null;
  220.                   $idclient null;
  221.                   $action "Creation compte client";
  222.                   $msg_send "Creation";
  223.                   $msg_get $resp['message'];
  224.                   $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  225.                   $entityManager->persist($log);
  226.                   $entityManager->flush();
  227.                   return $this->redirectToRoute('app_register');
  228.                 } else {
  229.                   if ($resp['statut'] == 405) {
  230.                     $error $session->get('message'$resp['message']);
  231.                     $this->addFlash('warning'$resp['message']);
  232.                     $iduser null;
  233.                     $idclient null;
  234.                     $action "Creation compte client";
  235.                     $msg_send "Creation";
  236.                     $msg_get $resp['message'];
  237.                     $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  238.                     $entityManager->persist($log);
  239.                     $entityManager->flush();
  240.                     return $this->redirectToRoute('app_register');
  241.                   } else {
  242.                     if ($resp['statut'] == 406) {
  243.                       $error $session->get('message'$resp['message']);
  244.                       $this->addFlash('warning'$resp['message']);
  245.                       $iduser null;
  246.                       $idclient null;
  247.                       $action "Creation compte client";
  248.                       $msg_send "Creation";
  249.                       $msg_get $resp['message'];
  250.                       $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  251.                       $entityManager->persist($log);
  252.                       $entityManager->flush();
  253.                       return $this->redirectToRoute('app_register');
  254.                     } else {
  255.                       if ($resp['statut'] == 407) {
  256.                         $error $session->get('message'$resp['message']);
  257.                         $this->addFlash('warning'$resp['message']);
  258.                         $iduser null;
  259.                         $idclient null;
  260.                         $action "Creation compte client";
  261.                         $msg_send "Creation";
  262.                         $msg_get $resp['message'];
  263.                         $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  264.                         $entityManager->persist($log);
  265.                         $entityManager->flush();
  266.                         return $this->redirectToRoute('app_register');
  267.                       } else {
  268.                         if ($resp['statut'] == 408) {
  269.                           $error $session->get('message'$resp['message']);
  270.                           $this->addFlash('warning'$resp['message']);
  271.                           $iduser null;
  272.                           $idclient null;
  273.                           $action "Creation compte client";
  274.                           $msg_send "Creation";
  275.                           $msg_get $resp['message'];
  276.                           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  277.                           $entityManager->persist($log);
  278.                           $entityManager->flush();
  279.                           return $this->redirectToRoute('app_register');
  280.                         } else {
  281.                           if ($resp['statut'] == 409) {
  282.                             $error $session->get('message'$resp['message']);
  283.                             $this->addFlash('warning'$resp['message']);
  284.                             $iduser null;
  285.                           $idclient null;
  286.                           $action "Creation compte client";
  287.                           $msg_send "Creation";
  288.                           $msg_get $resp['message'];
  289.                           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  290.                           $entityManager->persist($log);
  291.                           $entityManager->flush();
  292.                             return $this->redirectToRoute('app_register');
  293.                           } else {
  294.                             if ($resp['statut'] == 200) {
  295.                               $success $session->get('message'$resp['message']);
  296.                               $iduser null;
  297.                           $idclient null;
  298.                           $action "Creation compte client";
  299.                           $msg_send "Creation";
  300.                           $msg_get $resp['message'];
  301.                           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  302.                           $entityManager->persist($log);
  303.                           $entityManager->flush();
  304.                               // $this->addFlash('success',$resp['message']);
  305.                               return $this->redirectToRoute('app_authentication');
  306.                             }
  307.                           }
  308.                         }
  309.                       }
  310.                     }
  311.                   }
  312.                 }
  313.               }
  314.             }
  315.           }
  316.         }
  317.       }
  318.     }
  319.     return $this->render('authentication/register.html.twig', [
  320.       'typeClients' => $typeClients['typeClients'],
  321.     ]);
  322.   }
  323.   #[Route('/changePassword'name'app_changePassword')]
  324.   public function app_changePassword(Request $requestEntityManagerInterface $entityManager): Response
  325.   {
  326.     return $this->render('authentication/changePassword.html.twig', [
  327.       
  328.     ]);
  329.   }
  330.   #[Route('/sendCode'name'app_sendCode'methods: ['POST','GET'])]
  331.   public function app_sendCode(Request $requestEntityManagerInterface $entityManagerSession $session): Response
  332.   {
  333.     if ($request->request->count() > 0) {
  334.       $phone $request->request->get("phone");
  335.       $ch curl_init();
  336.       curl_setopt($chCURLOPT_URL"https://carenapi235679814.caren-niger.com/api/getnewpassword");
  337.       curl_setopt($chCURLOPT_POST1);
  338.       curl_setopt($chCURLOPT_POSTFIELDS'{
  339.             "username" : "' $phone '"
  340.           }');
  341.       $headers = array(
  342.         "Content-Type: application/json",
  343.         "Accept: application/json",
  344.       );
  345.       curl_setopt($chCURLOPT_HTTPHEADER$headers);
  346.       //for debug only!
  347.       curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
  348.       curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  349.       curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  350.       $server_output curl_exec($ch);
  351.       curl_close($ch);
  352.       $resp json_decode(preg_replace('/[\x00-\x1F\x80-\xFF]/'''$server_output), true);
  353.       // dd($resp);
  354.       if ($resp == null) {
  355.         $this->addFlash('NotifErrors'"Connexion avec l'api interrompu");
  356.         $iduser null;
  357.         $idclient null;
  358.         $action "Mot de passe oublié";
  359.         $msg_send "Envoi code";
  360.         $msg_get "Connexion avec l'api interrompu.";
  361.         $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  362.         $entityManager->persist($log);
  363.         $entityManager->flush();
  364.         return $this->redirectToRoute('app_sendCode');
  365.       } 
  366.       elseif($resp['retour'] == 201){
  367.           $this->addFlash('NotifErrors'$resp['message']);
  368.           $iduser null;
  369.           $idclient null;
  370.           $action "Mot de passe oublié";
  371.           $msg_send "Envoi code";
  372.           $msg_get $resp['message'];
  373.           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  374.           $entityManager->persist($log);
  375.           $entityManager->flush();
  376.           return $this->redirectToRoute('app_sendCode');
  377.       } 
  378.       elseif ($resp['retour'] == 400){
  379.           $this->addFlash('NotifErrors'$resp['message']);
  380.           $iduser null;
  381.           $idclient null;
  382.           $action "Mot de passe oublié";
  383.           $msg_send "Envoi code";
  384.           $msg_get $resp['message'];
  385.           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  386.           $entityManager->persist($log);
  387.           $entityManager->flush();
  388.           return $this->redirectToRoute('app_sendCode');
  389.       } 
  390.       elseif ($resp['retour'] == 200){
  391.             $this->addFlash('CodeEnvoyer''Le code de vérification a été envoyer avec succés');
  392.             $session->start();
  393.             $iduser null;
  394.             $idclient null;
  395.             $action "Mot de passe oublié";
  396.             $msg_send "Envoi Code ";
  397.             $msg_get "Envoi code reussie";
  398.             $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  399.             $entityManager->persist($log);
  400.             $entityManager->flush();
  401.             // set and get session attributes
  402.             $session->set('phone'$phone);
  403.             return $this->redirectToRoute('app_confirmCode');
  404.       }
  405.       
  406.     }
  407.     return $this->redirectToRoute('app_changePassword');
  408.   }
  409.   #[Route('/confirmCode'name'app_confirmCode'methods: ['POST','GET'])]
  410.   public function app_confirmCode(Request $requestEntityManagerInterface $entityManagerSession $session): Response
  411.   {
  412.     if ($request->request->count() > 0) {
  413.       $phone $session->get('phone');
  414.       $code $request->request->get("code");
  415.       // dd($phone, $code);
  416.       $ch curl_init();
  417.       curl_setopt($chCURLOPT_URL"https://carenapi235679814.caren-niger.com/api/confirmationCode");
  418.       curl_setopt($chCURLOPT_POST1);
  419.       curl_setopt($chCURLOPT_POSTFIELDS'{
  420.                 "telephone" : "' $phone '",
  421.                 "code" : "' $code '"
  422.             }');
  423.       $headers = array(
  424.         "Content-Type: application/json",
  425.         "Accept: application/json",
  426.       );
  427.       curl_setopt($chCURLOPT_HTTPHEADER$headers);
  428.       //for debug only!
  429.       curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
  430.       curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  431.       curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  432.       $server_output curl_exec($ch);
  433.       curl_close($ch);
  434.       $resp json_decode(preg_replace('/[\x00-\x1F\x80-\xFF]/'''$server_output), true);
  435.       // dd($resp);
  436.       if ($resp == null) {
  437.         $this->addFlash('NotifErrors'"Connexion avec l'api interrompu");
  438.         $iduser null;
  439.         $idclient null;
  440.         $action "Mot de passe oublié";
  441.         $msg_send "Confirmation code";
  442.         $msg_get "Connexion avec l'api interrompu.";
  443.         $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  444.         $entityManager->persist($log);
  445.         $entityManager->flush();
  446.         return $this->redirectToRoute('app_confirmCode');
  447.       } 
  448.       elseif($resp['retour'] == 201){
  449.           $this->addFlash('NotifErrors'$resp['message']);
  450.           $iduser null;
  451.           $idclient null;
  452.           $action "Mot de passe oublié";
  453.           $msg_send "Confirmation code";
  454.           $msg_get $resp['message'];
  455.           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  456.           $entityManager->persist($log);
  457.           $entityManager->flush();
  458.           return $this->redirectToRoute('app_confirmCode');
  459.       } 
  460.       elseif ($resp['retour'] == 400){
  461.           $this->addFlash('NotifErrors'$resp['message']);
  462.           $iduser null;
  463.           $idclient null;
  464.           $action "Mot de passe oublié";
  465.           $msg_send "Confirmation code";
  466.           $msg_get $resp['message'];
  467.           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  468.           $entityManager->persist($log);
  469.           $entityManager->flush();
  470.           return $this->redirectToRoute('app_confirmCode');
  471.       } 
  472.       elseif ($resp['retour'] == 200){
  473.             $this->addFlash('CodeExact''Le code de vérification est valide');
  474.             $iduser null;
  475.             $idclient null;
  476.             $action "Mot de passe oublié";
  477.             $msg_send "Confirmation code ";
  478.             $msg_get "Confirmation code avec succès";
  479.             $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  480.             $entityManager->persist($log);
  481.             $entityManager->flush();
  482.             // set and get session attributes
  483.             $session->set('code'$code);
  484.             return $this->redirectToRoute('app_changePassword_code');
  485.       }
  486.     }
  487.     return $this->render('authentication/confirmCode.html.twig', [
  488.       
  489.     ]);
  490.   }
  491.   #[Route('/changePassword_Code'name'app_changePassword_code'methods: ['POST','GET'])]
  492.   public function app_changePassword_Code(Request $requestEntityManagerInterface $entityManagerSession $session): Response
  493.   {
  494.     if ($request->request->count() > 0) {
  495.       $phone $session->get('phone');
  496.       $code $session->get("code");
  497.       $password $request->request->get("password");
  498.       $confirmPassword $request->request->get("confirm-password");
  499.       // dd($phone, $code, $password, $confirmPassword);
  500.       if ($password != $confirmPassword) {
  501.         $this->addFlash('pasIdentiques''Les 2 mots de passe saisis ne sont pas identiques');
  502.         return $this->redirectToRoute('app_changePassword_code');
  503.       } 
  504.       $ch curl_init();
  505.       curl_setopt($chCURLOPT_URL"https://carenapi235679814.caren-niger.com/api/Changepasswordforget");
  506.       curl_setopt($chCURLOPT_POST1);
  507.       curl_setopt($chCURLOPT_POSTFIELDS'{
  508.                 "telephone" : "' $phone '",
  509.                 "code" : "' $code '",
  510.                 "pass" : "' $password '"
  511.             }');
  512.       $headers = array(
  513.         "Content-Type: application/json",
  514.         "Accept: application/json",
  515.       );
  516.       curl_setopt($chCURLOPT_HTTPHEADER$headers);
  517.       //for debug only!
  518.       curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
  519.       curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  520.       curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  521.       $server_output curl_exec($ch);
  522.       curl_close($ch);
  523.       $resp json_decode(preg_replace('/[\x00-\x1F\x80-\xFF]/'''$server_output), true);
  524.       // dd($resp);
  525.       if ($resp == null) {
  526.         $this->addFlash('NotifErrors'"Connexion avec l'api interrompu");
  527.         $iduser null;
  528.         $idclient null;
  529.         $action "Mot de passe oublié";
  530.         $msg_send "Changement de mot de passe";
  531.         $msg_get "Connexion avec l'api interrompu.";
  532.         $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  533.         $entityManager->persist($log);
  534.         $entityManager->flush();
  535.         return $this->redirectToRoute('app_changePassword_code');
  536.       } 
  537.       elseif($resp['retour'] == 201){
  538.           $this->addFlash('NotifErrors'$resp['message']);
  539.           $iduser null;
  540.           $idclient null;
  541.           $action "Mot de passe oublié";
  542.           $msg_send "Changement de mot de passe";
  543.           $msg_get $resp['message'];
  544.           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  545.           $entityManager->persist($log);
  546.           $entityManager->flush();
  547.           return $this->redirectToRoute('app_changePassword_code');
  548.       } 
  549.       elseif ($resp['retour'] == 400){
  550.           $this->addFlash('NotifErrors'$resp['message']);
  551.           $iduser null;
  552.           $idclient null;
  553.           $action "Mot de passe oublié";
  554.           $msg_send "Changement de mot de passe";
  555.           $msg_get $resp['message'];
  556.           $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  557.           $entityManager->persist($log);
  558.           $entityManager->flush();
  559.           return $this->redirectToRoute('app_changePassword_code');
  560.       } 
  561.       elseif ($resp['retour'] == 200){
  562.             $iduser null;
  563.             $idclient null;
  564.             $action "Mot de passe oublié";
  565.             $msg_send "Changement de mot de passe";
  566.             $msg_get "Le mot de passe a été changer avec succès";
  567.             $log $this->log($action$msg_send$msg_get$iduser,$idclient);
  568.             $entityManager->persist($log);
  569.             $entityManager->flush();
  570.             $session->clear();
  571.             $this->addFlash('success''Le mot de passe a été changer avec succès');
  572.             return $this->redirectToRoute('app_authentication');
  573.       }
  574.     }
  575.     return $this->render('authentication/changePasswordCode.html.twig', [
  576.       
  577.     ]);
  578.   }
  579.   public function log($action$msg_send$msg_get$iduser$idclient)
  580.   {
  581.     $log = new Log();
  582.     $date = new \DateTime('now');
  583.     $ip $_SERVER['REMOTE_ADDR'];
  584.     if($iduser){
  585.       $log->setUser($iduser);
  586.     }
  587.     if($idclient){
  588.       $log->setClient($idclient);
  589.     }
  590.     $log->setAction($action);
  591.     $log->setDate($date);
  592.     $log->setIp($ip);
  593.     $log->setCanal("web");
  594.     $log->setMsgSend($msg_send);
  595.     $log->setMsgGet($msg_get);
  596.     return $log;
  597.   }
  598. }