简体   繁体   中英

Symfony2 Change Message “Bad credentials.” on login

I use Symfony2. When an user login on my app if there is an error the default message "Bad credentials." appear. I woud like to change the message. (I am not using FOSUser)

I'm following this page in symfony's doc:

http://symfony.com/doc/2.8/cookbook/security/form_login_setup.html

Its works to me.

{% if error %}
   <div>{{ error.messageKey|trans(error.messageData, 'security') }}   </div>
{% endif %}

Simply create a translation with the following key, or override the login view to make your own one, with your keys.

To solely override the message, create a translation key in app/Resources/translations/security.en.yml (example):

Invalid credentials.: Invalid credentials.

This key is defined in the security domain .

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