src/Controller/HomeController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Controller\UserInterface;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\HttpFoundation\Session\Session;
  7. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class HomeController extends AbstractController{
  10.     public function __construct(){
  11.     }
  12.     /**
  13.     * @Route("/", name="home_index")
  14.     */
  15.     public function index(Session $session){
  16.         if(count($this->get('security.token_storage')->getToken()->getUser()->getClients()) > 0)
  17.             $id $this->get('security.token_storage')->getToken()->getUser()->getClients()[0]->getId();
  18.         $role $this->get('security.token_storage')->getToken()->getUser()->getRoles()[0];
  19.         $user $this->getUser();
  20.         $userId $user->getId();
  21.         $resetToken $this->get('security.token_storage')->getToken()->getUser()->getResetPassword();
  22.         
  23.         $session->set("role"$role);
  24.         // 'message' => "You must change your password for more security"
  25.         if(!empty($resetToken)) {
  26.             $em $this->getDoctrine()->getManager();
  27.             $user->setResetPassword("");
  28.             $em->flush();
  29.         }
  30.        
  31.         // if($role === "ROLE_PROSPECT" || $role === "ROLE_SKAZE" || $role === "ROLE_ADMIN")
  32.             return $this->redirectToRoute('dashboard_index');
  33.         
  34.         // if(!isset($id))
  35.         //     throw $this->createNotFoundException('This page does not exist');
  36.         
  37.         // return $this->redirectToRoute('dashboard_show', [
  38.         //     'id' => $id
  39.         // ]);
  40.     }
  41. }