{% extends "PackagistWebBundle:user:packages.html.twig" %}

{% import "PackagistWebBundle::macros.html.twig" as macros %}

{% block content %}
    {% set isActualUser = app.user and app.user.username is same as(user.username) %}

    {% if backup_code %}
        <div class="alert alert-info">
            <p>If you lose your phone or otherwise can't get codes via your authenticator app, you can this one-time backup code to sign in: <code>{{ backup_code }}</code></p>
            <p><strong>Take a moment to record this in a safe place. This code will not be shown again!</strong></p>
        </div>
    {% endif %}

    <h2 class="title">
        {{ user.username }}
        {%- if not isActualUser %}
            <small>
                member since: {{ user.createdAt|date('M d, Y') }}
                {%- if is_granted('ROLE_ADMIN') %}
                    <a href="mailto:{{ user.email }}">{{ user.email }}</a>
                {%- endif %}
            </small>
        {%- endif %}
    </h2>

    <section class="row">
        {% if isActualUser %}
            <section class="col-md-3">
                {{ knp_menu_render('profile_menu', {currentClass: 'active', allow_safe_labels: true}) }}
            </section>
        {% endif %}

        <section class="{{ isActualUser ? 'col-md-9' : 'col-md-12' }}">
            {% if user.totpAuthenticationEnabled %}
                <p class="alert alert-success">
                    <span class="icon-lock"></span>
                    Two-factor authentication is currently <strong>enabled</strong>.
                </p>

                <p>Two-factor authentication is an extra layer of security for your Packagist account designed to ensure that you're the only person who can access your account, even if someone knows your password.</p>

                <a href="{{ path('user_2fa_disable', {name: user.username}) }}" class="text-danger">Disable two-factor authentication</a>
            {% else %}
                <p class="alert alert-warning">
                    <span class="icon-unlock"></span>
                    Two-factor authentication is currently <strong>disabled</strong>.
                </p>

                <p>Two-factor authentication is an extra layer of security for your Packagist account designed to ensure that you're the only person who can access your account, even if someone knows your password.</p>

                <a href="{{ path('user_2fa_enable', {name: user.username}) }}" class="btn btn-block btn-primary btn-lg">Enable two-factor authentication</a>
            {% endif %}
        </section>
    </section>
{% endblock %}
