From 2bb3b332f3570f277783ef120031db6e03bf8c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 9 Jul 2018 19:09:26 +0200 Subject: [PATCH] fix authentication error message --- Controller/LoginController.php | 18 ++++++++++++++---- Resources/views/Login/login.html.twig | 6 ++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Controller/LoginController.php b/Controller/LoginController.php index 75fef45ec..046b78678 100644 --- a/Controller/LoginController.php +++ b/Controller/LoginController.php @@ -5,10 +5,21 @@ namespace Chill\MainBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\SecurityContextInterface; +use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; class LoginController extends Controller { + /** + * + * @var AuthenticationUtils + */ + protected $helper; + + public function __construct(AuthenticationUtils $helper) + { + $this->helper = $helper; + } + /** * Show a login form * @@ -17,11 +28,10 @@ class LoginController extends Controller */ public function loginAction(Request $request) { - $helper = $this->get('security.authentication_utils'); return $this->render('ChillMainBundle:Login:login.html.twig', array( - 'last_username' => $helper->getLastUsername(), - 'error' => $helper->getLastAuthenticationError() + 'last_username' => $this->helper->getLastUsername(), + 'error' => $this->helper->getLastAuthenticationError() )); } diff --git a/Resources/views/Login/login.html.twig b/Resources/views/Login/login.html.twig index a4c3d622c..1ed31eac7 100644 --- a/Resources/views/Login/login.html.twig +++ b/Resources/views/Login/login.html.twig @@ -41,6 +41,7 @@ background-color: #333; color: white; text-align: center; + font-family: 'Open Sans'; } #content { @@ -69,7 +70,6 @@ width : 15em; text-align: right; display: inline-block; - font-family: 'Open Sans'; font-weight: 300; padding-right: 5px; } @@ -97,7 +97,9 @@
-

{{ error|trans }}

+ {% if error is not null %} +

{{ error.message|trans }}

+ {% endif %}