[CONTROLLER][ROUTES] Refactor controllers to use the new base class and remove controller from the class name

This commit is contained in:
Hugo Sales
2020-07-23 14:08:31 +00:00
committed by Hugo Sales
parent 2796ac5228
commit 56f74fffe8
4 changed files with 27 additions and 31 deletions

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Controller;
use App\Core\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class Security extends Controller
{
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
$last_username = $authenticationUtils->getLastUsername();
return ['_template' => 'security/login.html.twig', 'last_username' => $last_username, 'error' => $error];
}
public function logout()
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
}