{% 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 socialaccount_enabled %}
    {% include "socialaccount.html" %}
  {% endif %}

  {% if ldap_available %}
  <div class="col-md-4">
    <h4>LDAP Login</h4>
    <hr/>
    <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-3 control-label" for="id_username">{% trans "Username" %}</label>
        <div class="col-md-3">
          {{ 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-3 control-label" for="id_password">{% trans "Password" %}</label>
        <div class="col-md-3">
          {{ 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-4 col-md-offset-3">
          <button class="btn btn-success" type="submit">{% trans "Login" %}</button>
        </div>
      </div>
    </form>
  </div>
  {% endif %}
  {% if oidc_enabled %}
  <div class="col-md-4">
    <h4>{{ oidc_account_name }}</h4>
    <hr/>
    <a href="{% url 'oidc_authentication_init' %}">Login</a>
  </div>
  {% endif %}
  <div class="col-md-4">
    <h4>Local account</h4>
    <hr/>
    <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-3 control-label" for="id_username">{% trans "Username" %}</label>
        <div class="col-md-3">
          {{ 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-3 control-label" for="id_password">{% trans "Password" %}</label>
        <div class="col-md-3">
          {{ 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-4 col-md-offset-3">
          <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 %}
