src/Controller/Admin/SecurityController.php line 31

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by JosuĂ© Yannick Cruz Sandoval<josue.yannick@gmail.com>.
  4.  * User: jcruz
  5.  * Date: 20/09/19
  6.  * Time: 12:47 PM
  7.  */
  8. namespace App\Controller\Admin;
  9. use App\Controller\BaseController;
  10. use App\Entity\Agent;
  11. use App\Service\Encryptor;
  12. use App\Utils\DataCryptoUtils;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  18. /**
  19.  * Class LoginController
  20.  * @package App\Controller\Recruiters
  21.  */
  22. class SecurityController extends BaseController
  23. {
  24.     #[Route(path'/logout'name'admin_logout'methods: ['GET'])]
  25.     function logout() {}
  26.     #[Route(path'/login'name'admin_login')]
  27.     function login(AuthenticationUtils $authenticationUtils) :Response {
  28.         if ($this->getUser()) {
  29.             return $this->redirectToRoute('recruiters_home');
  30.         }
  31.         // get the login error if there is one
  32.         $error $authenticationUtils->getLastAuthenticationError();
  33.         // last username entered by the user
  34.         $lastUsername $authenticationUtils->getLastUsername();
  35.         return $this->render('recruiters/security/login.html.twig', [
  36.             'last_username' => $lastUsername,
  37.             'error' => $error
  38.         ]);
  39.     }
  40. }