<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use App\Services\Mailer;
use App\Entity\{User};
use App\Form\{ResetPassType, ForgotPassType};
class SecurityController extends AppBaseController
{
/**
* @Route("/admin/login", name="app_login")
*/
public function login(AuthenticationUtils $authenticationUtils): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
if($this->getUser()){
return $this->redirectToRoute('admin.homepage');
}
return $this->render('admin/security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
}
/**
* @Route("/logout", name="app_logout", methods={"GET"})
*/
public function logout(AuthenticationUtils $authenticationUtils)
{
$this->get('security.token_storage')->setToken(null);
return $this->redirect($this->generateUrl('app_login'));
}
}