From ef9eecfdeadd8e1ae172bedd1d9a22894843df81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P=2E?= Date: Thu, 19 Dec 2024 10:18:02 +0100 Subject: [PATCH] Untested login --- src/Controller/SecurityController.php | 18 ++++++++++++++++++ src/Entity/Building.php | 3 +-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/Controller/SecurityController.php diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php new file mode 100644 index 0000000..082a7af --- /dev/null +++ b/src/Controller/SecurityController.php @@ -0,0 +1,18 @@ +json([ + $this->getUser()?->getId() ?? null + ]); + } +} diff --git a/src/Entity/Building.php b/src/Entity/Building.php index 0d7cb22..3f904d7 100644 --- a/src/Entity/Building.php +++ b/src/Entity/Building.php @@ -16,8 +16,7 @@ use Symfony\Component\Serializer\Attribute\Groups; operations: [ new Get(normalizationContext: ['groups' => 'building:item']), new GetCollection(normalizationContext: ['groups' => 'building:list']), - // TODO Security!! - new Post(), + new Post(security: "is_granted('ROLE_USER')"), ], order: ['name' => 'DESC'], paginationEnabled: false,