1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\AdminBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Kunstmaan\AdminBundle\Form\UserLoginType; |
6
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
7
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
8
|
|
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; |
9
|
|
|
|
10
|
|
|
class SecurityController extends AbstractController |
11
|
|
|
{ |
12
|
|
|
/** @var AuthenticationUtils */ |
13
|
|
|
private $authenticationUtils; |
14
|
|
|
|
15
|
|
|
public function __construct(AuthenticationUtils $authenticationUtils) |
16
|
|
|
{ |
17
|
|
|
$this->authenticationUtils = $authenticationUtils; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @Route("/login", name="cms_login", methods={"GET", "POST"}) |
22
|
|
|
* @Route("/login", name="fos_user_security_login", methods={"GET", "POST"}) |
23
|
|
|
*/ |
24
|
|
|
public function loginAction() |
25
|
|
|
{ |
26
|
|
|
$error = $this->authenticationUtils->getLastAuthenticationError(); |
27
|
|
|
$lastUsername = $this->authenticationUtils->getLastUsername(); |
28
|
|
|
$form = $this->createForm(UserLoginType::class); |
29
|
|
|
|
30
|
|
|
return $this->render( |
31
|
|
|
'@KunstmaanAdmin/Security/login_cms.html.twig', |
32
|
|
|
[ |
33
|
|
|
'form' => $form->createView(), |
34
|
|
|
'last_username' => $lastUsername, |
35
|
|
|
'error' => $error, |
36
|
|
|
] |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @Route("/logout", name="cms_logout") |
42
|
|
|
* @Route("/logout", name="fos_user_security_logout") |
43
|
|
|
*/ |
44
|
|
|
public function logoutAction() |
45
|
|
|
{ |
46
|
|
|
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|