Skip to content

Commit 44277c7

Browse files
committed
don't output message from AuthenticationException
Displaying the message of an `AuthenticationException` might expose sensitive data to the user.
1 parent 0507225 commit 44277c7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cookbook/security/form_login_setup.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ First, enable form login under your firewall:
2525
# app/config/security.yml
2626
security:
2727
# ...
28-
28+
2929
firewalls:
3030
default:
3131
anonymous: ~
@@ -98,7 +98,7 @@ under your ``form_login`` configuration (``/login`` and ``/login_check``):
9898
.. configuration-block::
9999

100100
.. code-block:: php-annotations
101-
101+
102102
// src/AppBundle/Controller/SecurityController.php
103103
// ...
104104
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
@@ -165,7 +165,7 @@ form::
165165

166166
// src/AppBundle/Controller/SecurityController.php
167167
// ...
168-
168+
169169
// ADD THIS use STATEMENT above your class
170170
use Symfony\Component\Security\Core\SecurityContextInterface;
171171

@@ -182,7 +182,7 @@ form::
182182
$error = $session->get(SecurityContextInterface::AUTHENTICATION_ERROR);
183183
$session->remove(SecurityContextInterface::AUTHENTICATION_ERROR);
184184
} else {
185-
$error = '';
185+
$error = null;
186186
}
187187

188188
// last username entered by the user
@@ -218,7 +218,7 @@ Finally, create the template:
218218
{# ... you will probably extends your base template, like base.html.twig #}
219219

220220
{% if error %}
221-
<div>{{ error.message }}</div>
221+
<div>{{ error.messageKey|trans(error.messageData) }}</div>
222222
{% endif %}
223223

224224
<form action="{{ path('login_check') }}" method="post">
@@ -471,4 +471,4 @@ any firewall. This means you can't check for security or even access the
471471
user object on these pages. See :doc:`/cookbook/controller/error_pages`
472472
for more details.
473473

474-
.. _`FOSUserBundle`: https://github.com/FriendsOfSymfony/FOSUserBundle
474+
.. _`FOSUserBundle`: https://github.com/FriendsOfSymfony/FOSUserBundle

0 commit comments

Comments
 (0)