web-dev-qa-db-ja.com

FOSUserBundle-BadCredentialsException

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')

解決策を見つけようとしましたが、結果が得られませんでした。

24
nowiko

Github変更ログ から:

[BCブレーク] FOSUserBundle:Security:login.html.twigテンプレートは、エラーメッセージではなくエラー変数でAuthenticationExceptionを受け取るようになりました。

この問題を修正するには、カスタムログインテンプレートを更新する必要がありますlogin.html.twig

から:

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

に:

{% if error %}
    ... {{ error.messageKey|trans(error.messageData, 'security') }} ...
{% endif %}
82
GG.