tokenStorage->getToken()->getUser(); if (!$user instanceof UserInterface) { throw new AccessDeniedException('This user does not have access to this section.'); } if (true === $request->getSession()->get('_fos_oauth_server.ensure_logout')) { $request->getSession()->invalidate(600); $request->getSession()->set('_fos_oauth_server.ensure_logout', true); } $event = $this->eventDispatcher->dispatch( new PreAuthorizationEvent($user, $this->getClient()) ); if ($event->isAuthorizedClient()) { $scope = $request->get('scope', null); return $this->oAuth2Server->finishClientAuthorization(true, $user, $request, $scope); } if (true === $this->authorizeFormHandler->process()) { return $this->processSuccess($user, $this->authorizeFormHandler, $request); } $contents = $this->twig->render( '@MauticApi/Authorize/oAuth2/authorize.html.twig', [ 'form' => $this->authorizeForm->createView(), 'client' => $this->getClient(), ] ); return new Response($contents); } }