1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace App\User\Communication\Controller; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
8
|
|
|
use Symfony\Component\HttpFoundation\Request; |
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
10
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
11
|
|
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; |
12
|
|
|
|
13
|
|
|
class Security extends Controller |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @Route("/", name="login") |
17
|
|
|
* @param Request $request |
18
|
|
|
* @param AuthenticationUtils $authenticationUtils |
19
|
|
|
* @return Response |
20
|
|
|
*/ |
21
|
|
|
public function login(Request $request, AuthenticationUtils $authenticationUtils): Response |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
$error = $authenticationUtils->getLastAuthenticationError(); |
24
|
|
|
|
25
|
|
|
$lastUsername = $authenticationUtils->getLastUsername(); |
26
|
|
|
|
27
|
|
|
return $this->render('user/security/login.html.twig', array( |
28
|
|
|
'last_username' => $lastUsername, |
29
|
|
|
'error' => $error, |
30
|
|
|
)); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* This is the route the user can use to logout. |
35
|
|
|
* |
36
|
|
|
* But, this will never be executed. Symfony will intercept this first |
37
|
|
|
* and handle the logout automatically. See logout in config/packages/security.yaml |
38
|
|
|
* |
39
|
|
|
* @Route("/logout", name="logout") |
40
|
|
|
* @throws \Exception |
41
|
|
|
*/ |
42
|
|
|
public function logout(): void |
43
|
|
|
{ |
44
|
|
|
throw new \RuntimeException('This should never be reached!'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* ONLY A PLACEHOLDER, FOR INDEX PAGE |
49
|
|
|
* @Route("/dashboard", name="dashboard") |
50
|
|
|
* |
51
|
|
|
* @param Request $request |
52
|
|
|
* @return Response |
53
|
|
|
*/ |
54
|
|
|
public function placeHolderFunction(Request $request): Response |
|
|
|
|
55
|
|
|
{ |
56
|
|
|
return $this->render('base.html.twig'); |
57
|
|
|
} |
58
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.