Ver código fonte

Fix bug introduces by 09334d81, now an admin must have the role ``ROLE_SONATA_ADMIN`` to see the top bar navigation

Thomas Rabaix 13 anos atrás
pai
commit
b2f361dbbe
2 arquivos alterados com 29 adições e 12 exclusões
  1. 4 0
      CHANGELOG.md
  2. 25 12
      Resources/views/standard_layout.html.twig

+ 4 - 0
CHANGELOG.md

@@ -1,6 +1,10 @@
 CHANGELOG
 CHANGELOG
 =========
 =========
 
 
+### 2012-06-05
+
+* [BC BREAK] Fix bug introduces by 09334d81, now an admin must have the role ``ROLE_SONATA_ADMIN`` to see the top bar navigation
+
 ### 2012-05-31
 ### 2012-05-31
 
 
 * Update batch action confirmation message (breaks some translations)
 * Update batch action confirmation message (breaks some translations)

+ 25 - 12
Resources/views/standard_layout.html.twig

@@ -84,19 +84,32 @@ file that was distributed with this source code.
                                 </a>
                                 </a>
                             {% endblock %}
                             {% endblock %}
                             <ul class="nav">
                             <ul class="nav">
+
                                 {% block sonata_top_bar_nav %}
                                 {% block sonata_top_bar_nav %}
-                                    {% for group in admin_pool.dashboardgroups %}
-                                        <li class="dropdown">
-                                            <a href="#" class="dropdown-toggle">{{ group.label|trans({}, group.label_catalogue) }}</a>
-                                            <ul class="dropdown-menu">
-                                                {% for admin in group.items %}
-                                                    {% if admin.hasroute('create') and admin.isGranted('CREATE') or admin.hasroute('list') and admin.isGranted('LIST') %}
-                                                        <li><a href="{{ admin.generateUrl('list')}}">{{ admin.label|trans({}, admin.translationdomain) }}</a></li>
-                                                    {% endif %}
-                                                {% endfor %}
-                                            </ul>
-                                        </li>
-                                    {% endfor %}
+                                    {# There is no hasRole in a TokenInterface ... #}
+                                    {% set allowed = false %}
+                                    {% if app.security %}
+                                        {% for role in app.security.token.roles %}
+                                            {% if not allowed %}
+                                                {% set allowed = role.role == 'ROLE_SONATA_ADMIN' %}
+                                            {% endif %}
+                                        {% endfor %}
+                                    {% endif %}
+
+                                    {% if allowed %}
+                                        {% for group in admin_pool.dashboardgroups %}
+                                            <li class="dropdown">
+                                                <a href="#" class="dropdown-toggle">{{ group.label|trans({}, group.label_catalogue) }}</a>
+                                                <ul class="dropdown-menu">
+                                                    {% for admin in group.items %}
+                                                        {% if admin.hasroute('create') and admin.isGranted('CREATE') or admin.hasroute('list') and admin.isGranted('LIST') %}
+                                                            <li><a href="{{ admin.generateUrl('list')}}">{{ admin.label|trans({}, admin.translationdomain) }}</a></li>
+                                                        {% endif %}
+                                                    {% endfor %}
+                                                </ul>
+                                            </li>
+                                        {% endfor %}
+                                    {% endif %}
                                 {% endblock %}
                                 {% endblock %}
                             </ul>
                             </ul>