Twig 中的 Symfony2 安全功能?如何查看用户的角色? [英] Symfony2 security functions in Twig? How to check the user's role?

查看:25
本文介绍了Twig 中的 Symfony2 安全功能?如何查看用户的角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了带有 JMSSecurityBundle 的 Symfony 2.0.9 标准版.只是想知道 Twig 模板中有哪些功能可供我用来处理用户?

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?

具体来说,我想检查用户是否具有角色 ROLE_ADMIN.

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

有什么帮助吗?

谢谢

推荐答案

{% if is_granted('ROLE_ADMIN') %} ... {% endif %}

这篇关于Twig 中的 Symfony2 安全功能?如何查看用户的角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆