1 | <?php |
||
16 | class TokenAuthenticator extends AbstractGuardAuthenticator |
||
17 | { |
||
18 | /** |
||
19 | * @var TranslatorInterface |
||
20 | */ |
||
21 | private $translator; |
||
22 | |||
23 | 11 | public function __construct(TranslatorInterface $translator) |
|
27 | |||
28 | 10 | public function supports(Request $request) |
|
32 | |||
33 | 3 | public function getCredentials(Request $request) |
|
37 | |||
38 | 2 | public function getUser($apiToken, UserProviderInterface $userProvider) |
|
53 | |||
54 | 1 | public function checkCredentials($credentials, UserInterface $user) |
|
62 | |||
63 | 1 | public function onAuthenticationFailure(Request $request, AuthenticationException $exception) |
|
64 | { |
||
65 | $data = [ |
||
66 | 1 | 'error' => $this->translator->trans('api_token_authentication_failure', [], 'error'), |
|
67 | 1 | 'error_description' => $this->translator->trans('api_token_authentication_failure_description', [], 'error'), |
|
68 | ]; |
||
69 | |||
70 | 1 | return new JsonResponse($data, Response::HTTP_FORBIDDEN); |
|
71 | } |
||
72 | |||
73 | 3 | public function start(Request $request, AuthenticationException $authException = null) |
|
82 | |||
83 | public function supportsRememberMe() |
||
87 | |||
88 | 1 | public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) |
|
92 | } |