diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php index 7cb5102e97..d2d77f0a13 100644 --- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php @@ -191,7 +191,9 @@ class UsernamePasswordJsonAuthenticationListener extends AbstractListener implem } if (!$this->failureHandler) { - return new JsonResponse(['error' => $failed->getMessageKey()], 401); + $errorMessage = strtr($failed->getMessageKey(), $failed->getMessageData()); + + return new JsonResponse(['error' => $errorMessage], 401); } $response = $this->failureHandler->onAuthenticationFailure($request, $failed);