77

I have Symfony 2.0.9 standard edition installed with JMSSecurityBundle. Just wondering what functions are available to me in a Twig template to deal with users?

Specifically I want check to see if a user has the role ROLE_ADMIN.

Any help?

Thanks

Chris Tickner
  • 2,008
  • 2
  • 20
  • 24

1 Answers1

256
{% if is_granted('ROLE_ADMIN') %} ... {% endif %}
Kris Wallsmith
  • 8,945
  • 1
  • 37
  • 25
  • 3
    Note that is_granted uses the roles on the current session: so if you have a new role and didn't login/out it will not work! – numediaweb Dec 11 '17 at 12:23