{% extends 'flask_user/public_base.html' %}

{% block content %}
{% from "flask_user/_macros.html" import render_field, render_checkbox_field, render_submit_field %}
<h1>{%trans%}Sign in{%endtrans%}</h1>

<form action="" method="POST" class="form" role="form">
    {{ form.hidden_tag() }}

    {# Username or Email field #}
    {% set field = form.username if user_manager.enable_username else form.email %}
    <div class="form-group {% if field.errors %}has-error{% endif %}">
        {# Label on left, "New here? Register." on right #}
        <div class="row">
            <div class="col-xs-6">
                <label for="{{ field.id }}" class="control-label">{{ field.label.text }}</label>
            </div>
            <div class="col-xs-6 text-right">
                {% if user_manager.enable_register and not user_manager.require_invitation %}
                    <a href="{{ url_for('user.register') }}" tabindex='190'>
                        {%trans%}New here? Register.{%endtrans%}</a>
                {% endif %}
            </div>
        </div>
        {{ field(class_='form-control', tabindex=110) }}
        {% if field.errors %}
            {% for e in field.errors %}
                <p class="help-block">{{ e }}</p>
            {% endfor %}
        {% endif %}
    </div>

    {# Password field #}
    {% set field = form.password %}
    <div class="form-group {% if field.errors %}has-error{% endif %}">
        {# Label on left, "Forgot your Password?" on right #}
        <div class="row">
            <div class="col-xs-6">
                <label for="{{ field.id }}" class="control-label">{{ field.label.text }}</label>
            </div>
            <div class="col-xs-6 text-right">
                {% if user_manager.enable_forgot_password %}
                    <a href="{{ url_for('user.forgot_password') }}" tabindex='195'>
                        {%trans%}Forgot your Password?{%endtrans%}</a>
                {% endif %}
            </div>
        </div>
        {{ field(class_='form-control', tabindex=120) }}
        {% if field.errors %}
            {% for e in field.errors %}
                <p class="help-block">{{ e }}</p>
            {% endfor %}
        {% endif %}
    </div>

    {# Remember me #}
    {% if user_manager.enable_remember_me %}
    {{ render_checkbox_field(login_form.remember_me, tabindex=130) }}
    {% endif %}

    {# Submit button #}
    {{ render_submit_field(form.submit, tabindex=180) }}
</form>

{% endblock %}