src/Controller/Admin/SecurityController.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use Symfony\Component\HttpFoundation\Response;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  8. use App\Entity\User;
  9. /**
  10.  * Controller managing security in the admin
  11.  *
  12.  * Class SecurityController
  13.  *
  14.  * @package App\Controller\Admin
  15.  */
  16. class SecurityController extends BaseAdminController
  17. {
  18.     /**
  19.      * @Route("/login", methods={"GET", "POST"}, name="admin_login")
  20.      */
  21.     public function login(AuthenticationUtils $authenticationUtils): Response
  22.     {
  23.          if ($this->getUser()) {
  24.             return $this->redirectToRoute('admin');
  25.          }
  26.         // get the login error if there is one
  27.         $error $authenticationUtils->getLastAuthenticationError();
  28.         // last username entered by the user
  29.         $lastUsername $authenticationUtils->getLastUsername();
  30.         return $this->render('admin/security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  31.     }   
  32.     /**
  33.      * @Route("/logout", methods={"GET"}, name="admin_logout")
  34.      */
  35.     public function logout()
  36.     {
  37.         throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
  38.     }
  39. }