In my home page template Index.html.twig I have one navigation bar which i only want to show to Admin users if they are logged in , othwise not.
I tried this
{% if is_granted('ROLE_ADMIN') %}
<div class="navigation">
</div>
{% endif %}
But i get this error
An exception has been thrown during the rendering of a template (“The
security context contains no authentication token. One possible reason
may be that there is no firewall configured for this URL.
Now as this is home page i can’t put it behind firewall. Is there any way to do it
Wrap in it an if block like so: