Closed hkdobrev closed 6 years ago
The right solution is to expose AuthenticationUtils IMO.
$app['security.last_error']
exposes the message of the last error instead of the AuthenticationException object, which indeed does not give access to the translation key suited for user display.
Got it. I didn't realise the AuthenticationUtils
class is actually returning an AuthenticationException
instance.
I'll try to tackle that in the next couple of days :) Seems like an easy fix now.
Found this question on StackOverflow: Silex, how to translate login error messages?
Looking the code it seems indeed the error message is not being translated:
https://github.com/silexphp/Silex/blob/e41379abc3e943fd5ff08e65158decca7af5748d/src/Silex/Provider/SecurityServiceProvider.php#L415-L429
Should we translate it if the translator is registered in the
'security.last_error'
callback or should we expose theAuthenticationUtils
class in the controllers like Symfony? I don't see translation of the message there as well.Any pointers?