src/Controller/Security/SecurityController.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Security;
  3. use App\Domain\Liquidacions\Service\Notifier;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. class SecurityController extends AbstractController
  9. {
  10.     /**
  11.      * @Route("/", name="app_main")
  12.      */
  13.     public function main(AuthenticationUtils $authenticationUtils): Response
  14.     {
  15.         if ($this->getUser()) {
  16.             return $this->redirectToRoute('perfil_index');
  17.         }
  18.         return $this->redirectToRoute('app_login');
  19.     }
  20.     /**
  21.      * @Route("/login", name="app_login")
  22.      */
  23.     public function login(AuthenticationUtils $authenticationUtilsNotifier $notifier): Response
  24.     {
  25.         if ($this->getUser()) {
  26.             $this->redirectToRoute('perfil_index');
  27.         }
  28.         /*$notifier->notifier("didacmartin@gmail.com",
  29.             "didacmartin@gmail.com",
  30.             'Documents d\'acord i proposta generats correctament',
  31.             'email/recovery_password.html.twig',
  32.             ['token' =>"caca"]
  33.         );*/
  34.         // get the login error if there is one
  35.         $error $authenticationUtils->getLastAuthenticationError();
  36.         // last username entered by the user
  37.         $lastUsername $authenticationUtils->getLastUsername();
  38.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  39.     }
  40.     /**
  41.      * @Route("/logout", name="app_logout")
  42.      *
  43.      * @throws \Exception
  44.      */
  45.     public function logout()
  46.     {
  47.         throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
  48.     }
  49. }