I want to know if the user has the role "VIEW_GEOLOC_DATA", but I have a problem using the twig is_granted() function.
If I use in the template:
Roles : {{ dump(app.user.getRoles()) }} is_granted('ROLE_SUPER_ADMIN') : {{ dump(is_granted('ROLE_SUPER_ADMIN')) }} is_granted('VIEW_GEOLOC_DATA') : {{ dump(is_granted('VIEW_GEOLOC_DATA')) }}
This is what I get when rendering:
array(2) { [0]=> string(16) "ROLE_SUPER_ADMIN" [1]=> string(16) "VIEW_GEOLOC_DATA" } is_granted('ROLE_SUPER_ADMIN') : bool(true) is_granted('VIEW_GEOLOC_DATA') : bool(false)
I tried to log in and out, omitting the symfony cache.
I also tried to switch the order of the roles in the array returned by my userβs getRoles () method: the is_granted function only considers the first role of the array
source share