diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 0c1b449c440322f7ca3713c9ed19c1b64afe76a9..3e008606ee2c3cf470442065a6404962ca9c8118 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -40,5 +40,5 @@ security: # Easy way to control access for large sections of your site # Note: Only the *first* access control that matches will be used access_control: - - { path: ^/admin, roles: ROLE_SUPER_ADMIN } +# - { path: ^/admin, roles: ROLE_SUPER_ADMIN } # - { path: ^/profile, roles: ROLE_USER } diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index e091a00f54b52e211a50a466c020fdbe6a0c8fc7..584996511d8b89d8910eb5d21db920bbfe0a015d 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -7,8 +7,10 @@ use App\Entity\Post; use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; class DashboardController extends AbstractDashboardController { @@ -17,6 +19,10 @@ class DashboardController extends AbstractDashboardController */ public function index(): Response { +// if (!$this->isGranted('ROLE_SUPER_ADMIN')){ +// throw new AccessDeniedException(); +// } + $this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN '); return parent::index(); } diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php index ca0723cccbb09cf95487a1631198c41febf22863..caa035e3144aad730769360dfff946ca4061431d 100644 --- a/src/DataFixtures/AppFixtures.php +++ b/src/DataFixtures/AppFixtures.php @@ -38,9 +38,15 @@ class AppFixtures extends Fixture $expiredUser->setExpiredAt(new \DateTime('-1 day')); $expiredUser->setPassword($this->userPasswordHasher->hashPassword($expiredUser, '123')); + $tom = new User(); + $tom->setUsername('tom'); + $tom->setPassword($this->userPasswordHasher->hashPassword($tom, 'tom')); + + $manager->persist($admin); $manager->persist($deletedUser); $manager->persist($expiredUser); + $manager->persist($tom); $manager->flush(); }