src/Controller/SecurityController.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  8. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  9. use Symfony\Component\Form\FormError;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\JsonResponse;
  12. use App\Services\Mailer;
  13. use App\Entity\{User};
  14. use App\Form\{ResetPassTypeForgotPassType};
  15. class SecurityController extends AppBaseController
  16. {
  17.     /**
  18.      * @Route("/admin/login", name="app_login")
  19.      */
  20.     public function login(AuthenticationUtils $authenticationUtils): Response
  21.     {   
  22.         $error $authenticationUtils->getLastAuthenticationError();
  23.         $lastUsername $authenticationUtils->getLastUsername();
  24.         if($this->getUser()){
  25.             return $this->redirectToRoute('admin.homepage');
  26.         }
  27.         return $this->render('admin/security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  28.     }
  29.     /**
  30.      * @Route("/logout", name="app_logout", methods={"GET"})
  31.      */
  32.     public function logout(AuthenticationUtils $authenticationUtils)
  33.     {
  34.         $this->get('security.token_storage')->setToken(null);
  35.         return $this->redirect($this->generateUrl('app_login'));
  36.     }
  37.    
  38.     
  39.     
  40. }