{% extends "layouts/content.html" %}
{% load i18n %}

{% block title %}{% trans "Sign in" %}{% endblock %}


{% block content %}
{% if next %}
<h2>{% trans "You need to sign in to access this page" %}</h2>
{% else %}
<h2>{% trans "Sign in" %}</h2>
{% endif %}


<div class="row">
  {% if ldap_available %}
  <div class="col-md-6">
    <h4 class="modal-header">LDAP Login</h4>
    <form class="form-horizontal" method="post" action="{% url 'login' %}">
      {% csrf_token %}
      <input type="hidden" name="next" value="{{ request.GET.next }}" />
      <div class="form-group{% if form.errors %} has-error{% endif %}">
        <p class="help-block">{{ login_message_ldap }}</p>
        <label class="col-md-2 control-label" for="id_username">{% trans "Username" %}</label>
        <div class="col-md-4">
          {{ form.username }}
          {% for error in form.username.errors %}
          <p class="help-block">{{ error }}</p>
          {% endfor %}
        </div>
      </div>
      <div class="form-group{% if form.errors %} has-error{% endif %}">
        <label class="col-md-2 control-label" for="id_password">{% trans "Password" %}</label>
        <div class="col-md-4">
          {{ form.password }}
          {% for error in form.password.errors %}
          <p class="help-block">{{ error }}</p>
          {% endfor %}
        </div>
      </div>
      <div class="form-group">
        <div class="col-md-6 col-md-offset-2">
          <button class="btn btn-success" type="submit">{% trans "Login" %}</button>
        </div>
      </div>
    </form>
  </div>
  {% endif %}
  <div class="col-md-6">
    <h4 class="modal-header">Local account</h4>
    <form class="form-horizontal" method="post" action="{% url 'login' %}">
      {% csrf_token %}
      <input type="hidden" name="next" value="{{ request.GET.next }}" />
      <div class="form-group{% if form.errors %} has-error{% endif %}">
        <label class="col-md-2 control-label" for="id_username">{% trans "Username" %}</label>
        <div class="col-md-4">
          {{ form.username }}
          {% for error in form.username.errors %}
          <p class="help-block">{{ error }}</p>
          {% endfor %}
        </div>
      </div>
      <div class="form-group{% if form.errors %} has-error{% endif %}">
        <label class="col-md-2 control-label" for="id_password">{% trans "Password" %}</label>
        <div class="col-md-4">
          {{ form.password }}
          {% for error in form.password.errors %}
          <p class="help-block">{{ error }}</p>
          {% endfor %}
        </div>
      </div>
      <div class="form-group">
        <div class="col-md-6 col-md-offset-2">
          <button class="btn btn-success" type="submit">{% trans "Login" %}</button>
          <a href="{% url 'password_reset' %}">{% trans "Reset password" %}</a>
        </div>
      </div>
    </form>
  </div>
</div>
{% endblock %}
