setAttribute(TwoFactorAuthenticator::FLAG_2FA_COMPLETE, true); return $token; } public function supports(Request $request): ?bool { if (str_contains($request->getRequestUri(), '/api/')) { // API docs can only be access, when the user is logged in if (str_contains($request->getRequestUri(), '/api/doc')) { return false; } return !$request->headers->has(self::HEADER_JAVASCRIPT); } return false; } public function authenticate(Request $request): Passport { return $this->authenticator->authenticate($request); } public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response { return $this->authenticator->onAuthenticationSuccess($request, $token, $firewallName); } public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response { return $this->authenticator->onAuthenticationFailure($request, $exception); } }