Example #1
0
 /**
  * @Route("/oauth/revok/{client_id}", name="claro_profile_applications_revoke")
  * @EXT\ParamConverter("user", options={"authenticatedUser" = true})
  * @ParamConverter("client", class="ClarolineCoreBundle:Oauth\Client", options={"id" = "client_id"})
  *
  * @Template()
  */
 public function revokAction(Request $request, User $user, Client $client)
 {
     /** @var \Symfony\Component\Translation\TranslatorInterface $translator */
     $translator = $this->get('translator');
     try {
         /** @var \Doctrine\Common\Persistence\ObjectManager $entityManager */
         $entityManager = $this->getDoctrine()->getManager();
         $criteria = array('client' => $client, 'user' => $user);
         $accessToken = $entityManager->getRepository('ClarolineCoreBundle:Oauth\\AccessToken')->findOneBy($criteria);
         $entityManager->remove($accessToken);
         $refreshToken = $entityManager->getRepository('ClarolineCoreBundle:Oauth\\RefreshToken')->findOneBy($criteria);
         if (null !== $refreshToken) {
             $entityManager->remove($refreshToken);
         }
         $authCodes = $entityManager->getRepository('ClarolineCoreBundle:Oauth\\AuthCode')->findBy($criteria);
         foreach ($authCodes as $authCode) {
             $entityManager->remove($authCode);
         }
         $entityManager->flush();
         $message = $translator->trans('application_revoked_success_message', array('%application%' => $client->getName()), 'api');
         $this->get('session')->getFlashBag()->add('success', $message);
     } catch (\Exception $exception) {
         $message = $translator->trans('application_revoked_error_message', array('%application%' => $client->getName()), 'api');
         $this->get('session')->getFlashBag()->add('error', $message);
     }
     return $this->redirect($this->generateUrl('claro_profile_applications'));
 }
Example #2
0
 public function hideClient(Client $client)
 {
     $client->hide();
     $this->om->persist($client);
     $this->om->flush();
 }
Example #3
0
 /**
  * @EXT\Route(
  *     "/delete/client/{client}",
  *     name="oauth_client_remove",
  *     options = {"expose"=true}
  * )
  * @SEC\PreAuthorize("canOpenAdminTool('platform_parameters')")
  *
  * @return Response
  */
 public function deleteClientAction(Client $client)
 {
     $oldid = $client->getId();
     $this->oauthManager->deleteClient($client);
     return new JsonResponse(array('id' => $oldid));
 }