-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Translate failure messages of json authentication #38037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate failure messages of json authentication #38037
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this one. It's definitely a feature (so targetting master is a good idea).
I don't think we have to add this to the UsernamePasswordJsonAuthenticationListener
(those are part of a system that will be removed in Symfony 6). If you can, I think it's also a good idea to add a test for this new feature.
src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php
Outdated
Show resolved
Hide resolved
My pleasure.
I will add a test. Takes some time^^ |
During writing the test i saw some other error messages like "Invalid username." (JsonLoginAuthenticator.php#L167). What do you think about the other error messages. Should they also translated see "Invalid JSON." or "The key "username" must be provided." |
i figure we can re-use a bunch of translations from the validator domain. |
no wait, i dont think http exceptions need to be translated at all. Usually they are caught by an ExceptionListener exposing the http status text in prod (while preserving the original message in dev). In this case im fine with only translating the responses generated here 👍 |
Please note that the symfony/src/Symfony/Component/Security/Core/Resources/translations/security.en.xlf Lines 17 to 20 in 485e59f
|
@malteschlueter looks like the PR already needs a rebase 🙈 |
Thank you @malteschlueter. |
…cation (Malte Schlüter) This PR was merged into the 5.2-dev branch. Discussion ---------- Add tests for translated error messages of json authentication | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #33168 | License | MIT | Doc PR | - In PR #38037 i added the translator to the json authenticator but there are some tests missing. I added some now. Commits ------- b50fc19 Add tests for translated error messages of json authentication
This PR was squashed before being merged into the 2.x branch. Discussion ---------- Translate message errors Hi `@chalasr`, The exception messages are not translated even if the locale was set. I largely ~copied~ inspired my code from this PR: symfony/symfony#38037 to translate the message. Let me know if any changes need to be done. Commits ------- 7c7bf70 Translate message errors
Until now the failure messages of the json authentication were not translated. I'm not sure if it's a bug or a new feature. The changes shouldn't be a BC.