1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-12 16:58:37 +00:00

Added relation between API Client and User

Fix #2062
This commit is contained in:
Nicolas Lœuillet 2016-10-24 21:56:28 +02:00
parent 8e58be9fb6
commit 23406ca3f1
No known key found for this signature in database
GPG key ID: BDC1EFB5CA0145F2
4 changed files with 95 additions and 3 deletions

View file

@ -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();