Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FOSUserBundle - BadCredentialsException

I use FOSUserBundle to provide user authorization and registration. Everything works fine, but when I try to log in using a non-existing username, I get this error:

exception 'Symfony\Component\Security\Core\Exception\BadCredentialsException'
with message 'Bad credentials' in
/var/www/OnTheWay/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php:73
Stack trace:
#0 /var/www/OnTheWay/app/cache/dev/classes.php(120): session_start()
#1 /var/www/OnTheWay/app/cache/dev/classes.php(198): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
#2 /var/www/OnTheWay/app/cache/dev/classes.php(498): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag('attributes')

I've tried finding a solution, but I didn't get any results.

like image 491
nowiko Avatar asked Oct 13 '14 13:10

nowiko


1 Answers

From the Github changelog:

[BC break] The FOSUserBundle:Security:login.html.twig template now receives an AuthenticationException in the error variable rather than an error message.

To fix the issue, you need to update your custom login template login.html.twig:

From:

{% if error %}
    ... {{ error|trans }} ...
{% endif %}

To:

{% if error %}
    ... {{ error.messageKey|trans(error.messageData, 'security') }} ...
{% endif %}
like image 50
GG. Avatar answered Oct 21 '22 06:10

GG.