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

{% block title %}{% trans %}Log in!{% endtrans %}{% endblock %}

{% block body %}
    <section class="frame-section">
        <form class="section-form" method="post">
            <fieldset class="container-block">
                <legend class="section-form-legend">
                    <h1>{% trans %}Login{% endtrans %}</h1>
                </legend>

                {% if error %}
                    <label class="alert alert-danger">
                        {{ error.getMessage() }}
                    </label>
                {% endif %}

                {% if app.user %}
                    <span>
                        {% trans %}You are logged in as %app.user.username%{% endtrans %}
                        <button class="btn btn-lg btn-primary">
                            <a href="{{ path('app_logout') }}">{% trans %}Logout{% endtrans %}</a>
                        </button>
                    </span>
                {% else %}
                    <div class="form-row">
                        <label class="section-form-label" for="inputNicknameOrEmail">{% trans %}Nickname or Email{% endtrans %}</label>
                        <input type="text" value="{{ last_login_id }}" name="_username" id="inputNicknameOrEmail" class="form-control" required autofocus>
                        <p class="help-text">{% trans %}Your nickname or email address{% endtrans %}</p>
                    </div>

                    <div class="form-row">
                        <label class="section-form-label" for="inputPassword">{% trans %}Password{% endtrans %}</label>
                        <input type="password" name="_password" id="inputPassword" class="form-control" required>
                        <p class="help-text">{% trans %}Your account's password{% endtrans %}</p>
                    </div>

                    <span class="form-row-checkbox">
                        <label for="inputRememberMe">{% trans %}Remember me{% endtrans %}</label>
                        <input type="checkbox" name="_remember_me" id="inputRememberMe">
                    </span>

                    {% if app.request.query.has('next') %}
                        <input type="hidden" name="_next" value="{{ app.request.query.get('next') }}">
                    {% endif %}
                    <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
                    <div>
                        <button id="signIn" class="btn btn-lg btn-primary" type="submit">Sign in</button>
                    </div>
                {% endif %}
            </fieldset>
        </form>
    </section>
{% endblock body %}

{% block javascripts %}{% endblock %}
