2020-07-22 10:58:25 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
2020-07-23 23:08:31 +09:00
|
|
|
use App\Core\Controller;
|
2020-07-22 10:58:25 +09:00
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
|
|
|
|
2020-07-23 23:08:31 +09:00
|
|
|
class Security extends Controller
|
2020-07-22 10:58:25 +09:00
|
|
|
{
|
|
|
|
public function login(AuthenticationUtils $authenticationUtils): Response
|
|
|
|
{
|
|
|
|
if ($this->getUser()) {
|
|
|
|
return $this->redirectToRoute('main_all');
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the login error if there is one
|
|
|
|
$error = $authenticationUtils->getLastAuthenticationError();
|
|
|
|
// last username entered by the user
|
2020-07-23 23:08:31 +09:00
|
|
|
$last_username = $authenticationUtils->getLastUsername();
|
2020-07-22 10:58:25 +09:00
|
|
|
|
2020-07-23 23:08:31 +09:00
|
|
|
return ['_template' => 'security/login.html.twig', 'last_username' => $last_username, 'error' => $error];
|
2020-07-22 10:58:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public function logout()
|
|
|
|
{
|
|
|
|
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
|
|
|
|
}
|
|
|
|
}
|