<?php
/**
* Created by Josué Yannick Cruz Sandoval<josue.yannick@gmail.com>.
* User: jcruz
* Date: 20/09/19
* Time: 12:47 PM
*/
namespace App\Controller\Admin;
use App\Controller\BaseController;
use App\Entity\Agent;
use App\Service\Encryptor;
use App\Utils\DataCryptoUtils;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
/**
* Class LoginController
* @package App\Controller\Recruiters
*/
class SecurityController extends BaseController
{
#[Route(path: '/logout', name: 'admin_logout', methods: ['GET'])]
function logout() {}
#[Route(path: '/login', name: 'admin_login')]
function login(AuthenticationUtils $authenticationUtils) :Response {
if ($this->getUser()) {
return $this->redirectToRoute('recruiters_home');
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('recruiters/security/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error
]);
}
}