Skip to content

Commit

Permalink
Remove deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
MatTheCat committed Jun 29, 2023
1 parent 987a1da commit 06e0b16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Expand Up @@ -34,6 +34,8 @@
*/
class AccessTokenAuthenticator implements AuthenticatorInterface
{
private ?TranslatorInterface $translator = null;

public function __construct(
private readonly AccessTokenHandlerInterface $accessTokenHandler,
private readonly AccessTokenExtractorInterface $accessTokenExtractor,
Expand Down Expand Up @@ -80,7 +82,11 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
return $this->failureHandler->onAuthenticationFailure($request, $exception);
}

$errorMessage = strtr($exception->getMessageKey(), $exception->getMessageData());
if (null !== $this->translator) {
$errorMessage = $this->translator->trans($exception->getMessageKey(), $exception->getMessageData(), 'security');
} else {
$errorMessage = strtr($exception->getMessageKey(), $exception->getMessageData());
}

return new Response(
null,
Expand All @@ -91,7 +97,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio

public function setTranslator(?TranslatorInterface $translator)
{
trigger_deprecation('symfony/security-http', '6.2', '"%s()" has no effect and will be removed in 7.0.', __METHOD__);
$this->translator = $translator;
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Security/Http/CHANGELOG.md
Expand Up @@ -11,7 +11,6 @@ CHANGELOG
* Add `$lifetime` parameter to `LoginLinkHandlerInterface::createLoginLink()`
* Add RFC6750 Access Token support to allow token-based authentication
* Allow using expressions as `#[IsGranted()]` attribute and subject
* Deprecate `AccessTokenAuthenticator::setTranslator`, it has no effect and should not be called

6.0
---
Expand Down

0 comments on commit 06e0b16

Please sign in to comment.