From 23406ca3f12303759ecb46974d6bcb22fb0e037b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 24 Oct 2016 21:56:28 +0200 Subject: Added relation between API Client and User Fix #2062 --- src/Wallabag/ApiBundle/Controller/DeveloperController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/ApiBundle/Controller/DeveloperController.php') diff --git a/src/Wallabag/ApiBundle/Controller/DeveloperController.php b/src/Wallabag/ApiBundle/Controller/DeveloperController.php index 5a36a260..550c0608 100644 --- a/src/Wallabag/ApiBundle/Controller/DeveloperController.php +++ b/src/Wallabag/ApiBundle/Controller/DeveloperController.php @@ -19,7 +19,7 @@ class DeveloperController extends Controller */ public function indexAction() { - $clients = $this->getDoctrine()->getRepository('WallabagApiBundle:Client')->findAll(); + $clients = $this->getDoctrine()->getRepository('WallabagApiBundle:Client')->findByUser($this->getUser()->getId()); return $this->render('@WallabagCore/themes/common/Developer/index.html.twig', [ 'clients' => $clients, @@ -38,7 +38,7 @@ class DeveloperController extends Controller public function createClientAction(Request $request) { $em = $this->getDoctrine()->getManager(); - $client = new Client(); + $client = new Client($this->getUser()); $clientForm = $this->createForm(ClientType::class, $client); $clientForm->handleRequest($request); @@ -75,6 +75,10 @@ class DeveloperController extends Controller */ public function deleteClientAction(Client $client) { + if (null === $this->getUser() || $client->getUser()->getId() != $this->getUser()->getId()) { + throw $this->createAccessDeniedException('You can not access this client.'); + } + $em = $this->getDoctrine()->getManager(); $em->remove($client); $em->flush(); -- cgit v1.2.3 From 21e7ccef3d960f4747d58fc0c9e081618e9451eb Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 14 Dec 2016 11:54:30 +0100 Subject: Fix tests & deprecation notice --- src/Wallabag/ApiBundle/Controller/DeveloperController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/ApiBundle/Controller/DeveloperController.php') diff --git a/src/Wallabag/ApiBundle/Controller/DeveloperController.php b/src/Wallabag/ApiBundle/Controller/DeveloperController.php index 550c0608..9cb1b626 100644 --- a/src/Wallabag/ApiBundle/Controller/DeveloperController.php +++ b/src/Wallabag/ApiBundle/Controller/DeveloperController.php @@ -42,7 +42,7 @@ class DeveloperController extends Controller $clientForm = $this->createForm(ClientType::class, $client); $clientForm->handleRequest($request); - if ($clientForm->isValid()) { + if ($clientForm->isSubmitted() && $clientForm->isValid()) { $client->setAllowedGrantTypes(['token', 'authorization_code', 'password', 'refresh_token']); $em->persist($client); $em->flush(); -- cgit v1.2.3