Symfony 5 : @IsGranted on method annotation doesn't work on inherited role Symfony 5 : @IsGranted on method annotation doesn't work on inherited role symfony symfony

Symfony 5 : @IsGranted on method annotation doesn't work on inherited role


You're requiring the user be granted two roles. Change your hierarchy to make ROLE_SUPER_ADMIN inherit ROLE_RESPONSIBLE so you can remove it or change the annotation to :

/** * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_RESPONSIBLE')") */


I think your admin need to have ROLE_RESPONSIBLE too since you provide an array of roles in your @isGranted() annotation./** * @Route("/page/{!page}", name="user_index", requirements={"page"="\d+"}, defaults={"page":1}) * @IsGranted({"ROLE_ADMIN", "ROLE_RESPONSIBLE"}) */public function ...