src/Controller/SecurityController.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. class SecurityController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/login", name="app_login")
  13.      */
  14.     public function login(AuthenticationUtils $authenticationUtils): Response
  15.     {
  16.         if ($this->getUser()) {
  17.             // redirect to admin area if already logged in
  18.             return new RedirectResponse($this->generateUrl('easyadmin'));
  19.         }
  20.         return $this->render('admin/login.html.twig', [
  21.             'error' => $authenticationUtils->getLastAuthenticationError(),
  22.         ]);
  23.     }
  24.     /**
  25.      * @Route("/logout", name="app_logout")
  26.      */
  27.     public function logout(Request $requestResponse $responseTokenInterface $token)
  28.     {
  29.         // Your custom logic here, for example:
  30.         $request->getSession()->getFlashBag()->add('notice''You have been logged out successfully.');
  31.     }
  32. }