{% extends "allauth_ens/base.html" %}
{% load i18n %}
{% load account socialaccount allauth_ens %}

{% block title %}{% trans "Sign In" %}{% endblock %}
{% block header-title %}{% trans "Sign In" %}{% endblock %}

{% block messages-extra %}
{% if form.errors or user.is_authenticated %}
  <div class="messages-container">
    <ul class="messages-list">
      {% if form.errors %}
        <li class="message error">
          {% blocktrans %}
          Authentication failed. Please check your credentials and try again.
          {% endblocktrans %}
        </li>
      {% endif %}
      {% if user.is_authenticated %}
        <li class="message warning">
          {% user_display user as user_str %}
          {% blocktrans %}
          Your are authenticated as {{ user_str }}, but are not authorized to access
          this page. Would you like to login to a different account ?
          {% endblocktrans %}
        </li>
      {% endif %}
    </ul>
  </div>
{% endif %}
{% endblock %}

{% block content-extra-classes %}{% is_clipper_highlighted as highlight_clipper %}{% if highlight_clipper %}highlight-clipper{% endif %}{% endblock %}

{% block content %}

{% get_providers as socialaccount_providers %}

{% is_clipper_highlighted as highlight_clipper %}

{% if highlight_clipper %}
  <section class="main-login-choices">
    <ul>
      <li><a title="Clipper" href="{% provider_login_url "clipper" process="login" scope=scope auth_params=auth_params %}">{% trans "Connect with Clipper" %}</a></li>
      <li><a title="{% trans "Other choices" %}" href="javascript:void(0);" onclick="$('.content-wrapper').toggleClass('not-clipper')">{% trans "Other ways to sign in/sign up" %}</a></li>
    </ul>
  </section>
{% endif %}
    
{% if socialaccount_providers %}
<section id="providers">
  <ul class="method-list">
    {% include "socialaccount/snippets/provider_list.html" with process="login" %}
  </ul>
</section>

{% include "socialaccount/snippets/login_extra.html" %}

<div class="divider"></div>

{% endif %}

<section id="main">
  <p>
    {% blocktrans %}
    Please sign in with one of your existing third party accounts, or with the form below.
    {% endblocktrans %}
  </p>
  <ul class="actions">
    <li><a href="{% url "account_reset_password" %}">{% trans "Forgot Password?" %}</a>
    {% is_open_for_signup as open_signup %}
    {% if open_signup %}
      <li><a href="{{ signup_url }}">{% trans "Sign Up" %}</a></li>
    {% endif %}
  </ul>
  <form action="{% url "account_login" %}" method="post">
    {% include "allauth_ens/block-form.html" with form=form %}
    <input type="submit" value="{% trans "Sign In" %}">
    {% if redirect_field_value %}
    <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}">
    {% endif %}
  </form>
</section>
{% endblock %}

{% block extra_js %}

{{ block.super }}

<script type="text/javascript">
  $( function() { prepareShorcuts(); } );
</script>

{% endblock %}
