src/Controller/SecurityController.php line 21

Open in your IDE?
  1. <?php 
  2. namespace App\Controller;
  3. use App\Entity\Users;
  4. use App\Repository\PaniersRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  11. class SecurityController extends AbstractController
  12. {
  13.     /**
  14.      * @Route("/login", name="login")
  15.      */
  16.     public function login(AuthenticationUtils $authenticationUtils){
  17.         $error $authenticationUtils->getLastAuthenticationError();
  18.         $last_username=$authenticationUtils->getLastUsername();
  19.         
  20.         return $this->render('security/login.html.twig',[
  21.             'error' => $error,
  22.             'last_username' => $last_username
  23.             ]
  24.         );
  25.     }
  26.         /**
  27.      * @Route("/logincrm", name="logincrm")
  28.      */
  29.      public function loginsalarie(AuthenticationUtils $authenticationUtils){
  30.         $error $authenticationUtils->getLastAuthenticationError();
  31.         $last_username=$authenticationUtils->getLastUsername();
  32.         
  33.         return $this->render('security/logincrm.html.twig',[
  34.             'error' => $error,
  35.             'last_username' => $last_username
  36.             ]
  37.         );
  38.     }
  39.        /**
  40.      * @Route("/login_success", name="login_success")
  41.      */
  42.     public function postLoginRedirectAction()
  43.     {
  44.               
  45.       
  46.             if( $this->isGranted('ROLE_ADMIN') || $this->isGranted('ROLE_SALARIE') ) {
  47.                 return $this->redirectToRoute("crm.tdb");
  48.             } elseif( $this->isGranted('ROLE_USER') ) 
  49.             {
  50.                 return $this->redirectToRoute("dashboard.tdb");
  51.             } 
  52.             elseif( $this->isGranted('ROLE_PRESTA') ) 
  53.             {
  54.                 return $this->redirectToRoute("prestataires.tdb");
  55.             } else {
  56.                 return $this->redirectToRoute("login");
  57.             }
  58.             
  59.        
  60.     }
  61. }
  62. ?>