FOSUserBundle - BadCredentialsException

now*_*iko 24 php symfony fosuserbundle

我使用FOSUserBundle提供用户授权和注册.一切正常,但当我尝试使用不存在的用户名登录时,我收到此错误:

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')
Run Code Online (Sandbox Code Playgroud)

我试过找到一个解决方案,但我没有得到任何结果.

GG.*_*GG. 82

来自Github更改日志:

[BC break] FOSUserBundle:Security:login.html.twig模板现在在错误变量中收到AuthenticationException而不是错误消息.

要解决此问题,您需要更新自定义登录模板login.html.twig:

从:

{% if error %}
    ... {{ error|trans }} ...
{% endif %}
Run Code Online (Sandbox Code Playgroud)

至:

{% if error %}
    ... {{ error.messageKey|trans(error.messageData, 'security') }} ...
{% endif %}
Run Code Online (Sandbox Code Playgroud)