Skip to content

Commit 9007625

Browse files
committed
updating SecurityController to a service
1 parent 890c25c commit 9007625

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

Controller/SecurityController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,24 @@
1111

1212
namespace FOS\UserBundle\Controller;
1313

14-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
14+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpFoundation\Session\Session;
1818
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1919
use Symfony\Component\Security\Core\Security;
20+
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
2021

21-
class SecurityController extends Controller
22+
class SecurityController extends AbstractController
2223
{
24+
private $tokenManager;
25+
26+
public function __construct(CsrfTokenManagerInterface $tokenManager = null)
27+
{
28+
$this->tokenManager = $tokenManager;
29+
}
30+
31+
2332
/**
2433
* @param Request $request
2534
*

Resources/config/routing/security.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
66

77
<route id="fos_user_security_login" path="/login" methods="GET POST">
8-
<default key="_controller">FOSUserBundle:Security:login</default>
8+
<default key="_controller">fos_user.security.controller:login</default>
99
</route>
1010

1111
<route id="fos_user_security_check" path="/login_check" methods="POST">
12-
<default key="_controller">FOSUserBundle:Security:check</default>
12+
<default key="_controller">fos_user.security.controller:check</default>
1313
</route>
1414

1515
<route id="fos_user_security_logout" path="/logout" methods="GET POST">
16-
<default key="_controller">FOSUserBundle:Security:logout</default>
16+
<default key="_controller">fos_user.security.controller:logout</default>
1717
</route>
1818

1919
</routes>

Resources/config/security.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
<service id="fos_user.user_provider.username_email" class="FOS\UserBundle\Security\EmailUserProvider" public="false">
3131
<argument type="service" id="fos_user.user_manager" />
3232
</service>
33+
34+
<service id="fos_user.security.controller" class="FOS\UserBundle\Controller\SecurityController" public="true">
35+
<argument type="service" id="security.csrf.token_manager" on-invalid="null" />
36+
</service>
3337
</services>
3438

3539
</container>

0 commit comments

Comments
 (0)