Skip to content

Commit 2ec651d

Browse files
dinamicdkarlovi
authored andcommitted
~ fixes to the security doc to make it compatible with sf3
1 parent 7930319 commit 2ec651d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Resources/doc/a_note_about_security.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ In the `loginAction()` of your `SecurityController`, just add few lines before t
1717
namespace Acme\SecurityBundle\Controller;
1818

1919
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;
2122

2223
class SecurityController extends Controller
2324
{
24-
public function loginAction()
25+
public function loginAction(Request $request)
2526
{
26-
$request = $this->getRequest();
2727
$session = $request->getSession();
2828

2929
// 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);
3232
} 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);
3535
}
3636

3737
// Add the following lines
@@ -43,7 +43,7 @@ class SecurityController extends Controller
4343

4444
return $this->render('AcmeSecurityBundle:Security:login.html.twig', array(
4545
// last username entered by the user
46-
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
46+
'last_username' => $session->get(Security::LAST_USERNAME),
4747
'error' => $error,
4848
));
4949
}

0 commit comments

Comments
 (0)