简体   繁体   中英

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.

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 %}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM