fix authentication error message

This commit is contained in:
Julien Fastré 2018-07-09 19:09:26 +02:00
parent 6ab86ac4fd
commit 2bb3b332f3
2 changed files with 18 additions and 6 deletions

View File

@ -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()
));
}

View File

@ -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 @@
<div id="content">
<img class="logo" src="/bundles/chillmain/img/logo-chill-outil-accompagnement_white.png">
<p>{{ error|trans }}</p>
{% if error is not null %}
<p>{{ error.message|trans }}</p>
{% endif %}
<form method="POST" action="{{ path('login_check') }}">
<label for="_username">{{ 'Username'|trans }}</label>