@@ -17,21 +17,21 @@ In the `loginAction()` of your `SecurityController`, just add few lines before t
17
17
namespace Acme\SecurityBundle\Controller;
18
18
19
19
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
20
- use Symfony\Component\Security\Core\SecurityContext;
20
+ use Symfony\Component\HttpFoundation\Request;
21
+ use Symfony\Component\Security\Core\Security;
21
22
22
23
class SecurityController extends Controller
23
24
{
24
- public function loginAction()
25
+ public function loginAction(Request $request )
25
26
{
26
- $request = $this->getRequest();
27
27
$session = $request->getSession();
28
28
29
29
// get the login error if there is one
30
- if ($request->attributes->has(SecurityContext ::AUTHENTICATION_ERROR)) {
31
- $error = $request->attributes->get(SecurityContext ::AUTHENTICATION_ERROR);
30
+ if ($request->attributes->has(Security ::AUTHENTICATION_ERROR)) {
31
+ $error = $request->attributes->get(Security ::AUTHENTICATION_ERROR);
32
32
} else {
33
- $error = $session->get(SecurityContext ::AUTHENTICATION_ERROR);
34
- $session->remove(SecurityContext ::AUTHENTICATION_ERROR);
33
+ $error = $session->get(Security ::AUTHENTICATION_ERROR);
34
+ $session->remove(Security ::AUTHENTICATION_ERROR);
35
35
}
36
36
37
37
// Add the following lines
@@ -43,7 +43,7 @@ class SecurityController extends Controller
43
43
44
44
return $this->render('AcmeSecurityBundle:Security:login.html.twig', array(
45
45
// last username entered by the user
46
- 'last_username' => $session->get(SecurityContext ::LAST_USERNAME),
46
+ 'last_username' => $session->get(Security ::LAST_USERNAME),
47
47
'error' => $error,
48
48
));
49
49
}
0 commit comments