Skip to content

Commit 36d2dd2

Browse files
committed
minor #1149 Translations for the security messages (b-durand)
This PR was squashed before being merged into the 2.0.x-dev branch (closes #1149). Discussion ---------- Translations for the security messages Error messages when an user wants to be authenticated should use the translations provided by the security component. Related to #1141. --- One more thing: I think that we should delete the entry "Bad credentials." in the translation of FOSUserBundle, but all languages in FOSUserBundle don't exist in translations of the security component, and the translation is not the same (diff between de or fr). Commits ------- a883bcb Translations for the security messages
2 parents 5a53273 + a883bcb commit 36d2dd2

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Controller/SecurityController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\DependencyInjection\ContainerAware;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\Security\Core\SecurityContextInterface;
17+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1718

1819
class SecurityController extends ContainerAware
1920
{
@@ -33,8 +34,12 @@ public function loginAction(Request $request)
3334
}
3435

3536
if ($error) {
36-
// TODO: this is a potential security risk (see http://trac.symfony-project.org/ticket/9523)
37-
$error = $error->getMessage();
37+
if ($error instanceof AuthenticationException) {
38+
$error = $error->getMessageKey();
39+
} else {
40+
// TODO: this is a potential security risk (see http://trac.symfony-project.org/ticket/9523)
41+
$error = $error->getMessage();
42+
}
3843
}
3944
// last username entered by the user
4045
$lastUsername = (null === $session) ? '' : $session->get(SecurityContextInterface::LAST_USERNAME);

Resources/views/Security/login.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% block fos_user_content %}
66
{% if error %}
7-
<div>{{ error|trans }}</div>
7+
<div>{{ error|trans({}, 'security') }}</div>
88
{% endif %}
99

1010
<form action="{{ path("fos_user_security_check") }}" method="post">

0 commit comments

Comments
 (0)