-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefaultController.php
33 lines (26 loc) · 973 Bytes
/
DefaultController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\HttpFoundation\Response;
class DefaultController extends AbstractController
{
/**
* @Route("/", name="homepage")
*/
public function indexAction(AuthenticationUtils $authenticationUtils): Response
{
if ($this->isGranted('ROLE_USER')) {
return $this->render('default/index.html.twig');
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('security/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
]);
}
}