{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %}

{% block toolbar %}
    {% if collector.user %}
        {% set color_code = (collector.enabled and collector.authenticated) ? 'green' : 'yellow'  %}
        {% set authentication_color_code = (collector.enabled and collector.authenticated) ? 'green' : 'red'  %}
        {% set authentication_color_text = (collector.enabled and collector.authenticated) ? 'Yes' : 'No'  %}
    {% else %}
        {% set color_code = collector.enabled ? 'red' : 'black'  %}
    {% endif %}
    {% set text %}
        {% if collector.user %}
            <div class="sf-toolbar-info-piece">
                <b>Logged in as</b>
                <span class="sf-toolbar-status sf-toolbar-status-{{ color_code }}">{{ collector.user }}</span>
            </div>
            <div class="sf-toolbar-info-piece">
                <b>Authenticated</b>
                <span class="sf-toolbar-status sf-toolbar-status-{{ authentication_color_code }}">{{ authentication_color_text }}</span>
            </div>
        {% elseif collector.enabled %}
            You are not authenticated.
        {% else %}
            The security is disabled.
        {% endif %}
    {% endset %}
    {% set icon %}
        <img width="24" height="28" alt="Security" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAcCAYAAAB75n/uAAAC70lEQVR42u2V3UtTYRzHu+mFwCwK+gO6CEryPlg7yiYx50vDqUwjFIZDSYUk2ZTmCysHvg9ZVggOQZiRScsR4VwXTjEwdKZWk8o6gd5UOt0mbev7g/PAkLONIOkiBx+25/v89vuc85zn2Q5Fo9F95UDwnwhS5HK5TyqVRv8m1JN6k+AiC+fn54cwbgFNIrTQ/J9IqDcJJDGBHsgDgYBSq9W6ysvLPf39/SSUUU7zsQ1yc3MjmN90OBzfRkZG1umzQqGIxPSTkIBjgdDkaGNjoza2kcFgUCE/QvMsq6io2PV6vQu1tbV8Xl7etkql2qqvr/+MbDE/Pz8s9OP2Cjhwwmw29+4R3Kec1WZnZ4fn5uamc3Jyttra2qbH8ero6JgdHh5+CvFHq9X6JZHgzODgoCVW0NPTY0N+ltU2Nzdv4GqXsYSrPp+vDw80aLFYxru6uhyQ/rDb7a8TCVJDodB1jUazTVlxcXGQ5/mbyE+z2u7u7veY38BVT3Z2djopm5qa6isrK/tQWVn5qb29fSGR4DC4PDAwMEsZHuArjGnyGKutq6v7ajQaF6urq9/MzMz0QuSemJiwQDwGkR0POhhXgILjNTU1TaWlpTxlOp1uyWQyaUjMajMzM8Nut/tJQUHBOpZppbCwkM/KytrBznuL9xDVxBMo8KXHYnu6qKjIivmrbIy67x6Px4Yd58W672ApfzY0NCyNjo7OZmRkiAv8fr+O47iwmABXtoXaG3uykF6vX7bZbF6cgZWqqiqezYkKcNtmjO+CF2AyhufgjsvlMiU7vXEF+4C4ALf9CwdrlVAqlcFkTdRqdQSHLUDgBEeSCrArAsiGwENs0XfJBE6ncxm1D8Aj/B6tigkkJSUlmxSwLYhMDeRsyyUCd+lHrWxtbe2aTCbbZTn1ZD92F0Cr8GBfgnsgDZwDt8EzMBmHMXBLqD0PDMAh9Gql3iRIESQSIAXp4CRIBZeEjIvDFZAm1J4C6UK9ROiZcvCn/+8FvwHtDdJEaRY+oQAAAABJRU5ErkJggg==" />
        <span class="sf-toolbar-status sf-toolbar-status-{{ color_code }}"></span>
        {% if collector.user %}<div class="sf-toolbar-status sf-toolbar-info-piece-additional">{{ collector.user }}</div>{% endif %}
    {% endset %}
    {% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %}
{% endblock %}

{% block menu %}
<span class="label">
    <span class="icon"><img src="{{ asset('bundles/webprofiler/images/profiler/security.png') }}" alt="" /></span>
    <strong>Security</strong>
</span>
{% endblock %}

{% block panel %}
    <h2>Security</h2>
    {% if collector.user %}
        <table>
            <tr>
                <th>Username</th>
                <td>{{ collector.user }}</td>
            </tr>
            <tr>
                <th>Authenticated?</th>
                <td>
                    {% if collector.authenticated %}
                        yes
                    {% else %}
                        no {% if not collector.roles|length %}<em>(probably because the user has no roles)</em>{% endif %}
                    {% endif %}
                </td>
            </tr>
            <tr>
                <th>Roles</th>
                <td>{{ collector.roles|yaml_encode }}</td>
            </tr>
        </table>
    {% elseif collector.enabled %}
        <p>
            <em>No token</em>
        </p>
    {% else %}
        <p>
            <em>The security component is disabled</em>
        </p>
    {% endif %}
{% endblock %}
