<?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 Symfony\Contracts\Translation\TranslatorInterface;
class LoginController extends AbstractController
{
/**
* @param AuthenticationUtils $authenticationUtils
* @return Response
* @Route("/system/login", name="system_login")
*/
public function adminLogin(AuthenticationUtils $authenticationUtils): Response
{
if ($this->getUser()) {
return $this->redirectToRoute('index');
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('Admin/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error
]);
}
/**
* @param AuthenticationUtils $authenticationUtils
* @return Response
* @Route("/konto/logowanie", name="store_login")
*/
public function login(AuthenticationUtils $authenticationUtils, TranslatorInterface $translator): Response
{
if ($this->getUser()) {
return $this->redirectToRoute('index');
}
$title = $translator->trans('Login to store');
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('Store/'.$this->storeData['storeTheme'].'/UserAccount/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
'title' => $title
]);
}
/**
* @Route("/logout", name="system_logout")
*/
public function logout()
{
return null;
}
}