Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@maryo
Copy link
Contributor

@maryo maryo commented Mar 12, 2014

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

Added username in UsernameNotFoundException message data

Added username in UsernameNotFoundException message data
@maryo
Copy link
Contributor Author

maryo commented Mar 12, 2014

NOTE: Travis failed because of "Pull Request License Headers". I edited the description so it is there but it probably didn't trigger the PR revalidation.

@fabpot
Copy link
Member

fabpot commented Mar 13, 2014

@maryo Can you add a unit test to cover this change?

maryo added 2 commits March 13, 2014 15:08
Added newline at the end of UsernameNotFoundExceptionTest.php
@maryo
Copy link
Contributor Author

maryo commented Mar 13, 2014

@fabpot Like this?

@romainneutron
Copy link
Contributor

Hello @maryo, can you describe the use case for this?

@maryo
Copy link
Contributor Author

maryo commented Mar 30, 2014

@romainneutron: Just because i want to display a better message to the user.

'User "John Doe" could not be found.'
instead of
'Username could not be found.'

AuthenticationException have getMessageKey() and getMessageData() methods with comment "Message data to be used by the translation component.".

These methods are not used in the framework at all. But in my case i have my own AuthenticationFailureHandler which returns JsonResponse (REST API). I use translator to translate the AuthenticationException there.

$this->translator->trans($exception->getMessageKey(), $exception->getMessageData(), 'exceptions')

BTW i have these methods on some other exceptions too. That's why the translation domain is set to "exceptions".

@romainneutron
Copy link
Contributor

Then getMessageKey return value should be updated. In the current implementation, there is no placeholder for {{ username }} variable in the message key.

@maryo
Copy link
Contributor Author

maryo commented Jun 3, 2014

@romainneutron I can add it but is it a good idea to show the username as a default behavior?... User can easily use the placeholder in translations. That was the point of the PR.

@fabpot
Copy link
Member

fabpot commented Jun 3, 2014

Actually I think that displaying the username by default is not a good practice. I mean, the user know what it enters, and this is probably already displayed in the form.

@stof
Copy link
Member

stof commented Jun 3, 2014

I agree with @fabpot here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants