{% extends 'base.html.twig' %}

{% block content %}
    <section>
        <h1>Log in</h1>

        {% if app.user %}
            <p>
                You are logged in as {{ app.user.userIdentifier }}.
                If you're not happy about that, <a href="{{ path('logout') }}">log out</a>.
            </p>
        {% else %}
            {% if error %}
                <div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
            {% endif %}

            <form action="{{ path('login') }}" method="POST">
                <label for="username">Email</label>
                <input
                    type="email"
                    value="{{ lastUsername }}"
                    name="_username"
                    id="username"
                    class="form-control"
                    autocomplete="email"
                    required
                    autofocus
                >

                <label for="password">Password</label>
                <input
                    type="password"
                    name="_password"
                    id="password"
                    class="form-control"
                    autocomplete="current-password"
                    required
                >

                <input type="hidden" name="_target_path" value="{{ path('index') }}">
                <input type="hidden" name="_csrf_token" data-controller="csrf-protection" value="{{ csrf_token('authenticate') }}">

                <button type="submit">Log in</button>
            </form>
        {% endif %}
    </section>
{% endblock %}
