{% extends "account/base.html" %}

{% load inventree_extras %}
{% load i18n account socialaccount crispy_forms_tags inventree_extras %}

{% block head_title %}{% trans "Sign In" %}{% endblock %}

{% block content %}

{% settings_value 'LOGIN_ENABLE_REG' as enable_reg %}
{% settings_value 'LOGIN_ENABLE_PWD_FORGOT' as enable_pwd_forgot %}
{% settings_value 'LOGIN_ENABLE_SSO' as enable_sso %}
{% inventree_customize 'login_message' as login_message %}
{% mail_configured as mail_conf %}

<h1>{% trans "Sign In" %}</h1>

{% if enable_reg %}
{% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
<p>{% blocktrans with site.name as site_name %}Please sign in with one
of your existing third party accounts or  <a class="btn btn-primary btn-small" href="{{ signup_url }}">sign up</a>
for a account and sign in below:{% endblocktrans %}</p>
{% else %}
<p>{% blocktrans %}If you have not created an account yet, then please
<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
{% endif %}
{% endif %}

<form class="login" method="POST" action="{% url 'account_login' %}">
  {% csrf_token %}
  {{ form|crispy }}
  {% if redirect_field_value %}
  <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
  {% endif %}

  <hr>
  {% if login_message %}
  <div>{{ login_message | safe }}<hr></div>
  {% endif %}
  <div class="btn-group float-right" role="group">
    <button class="btn btn-success" type="submit">{% trans "Sign In" %}</button>
  </div>
  {% if mail_conf and enable_pwd_forgot %}
  <a class="" href="{% url 'account_reset_password' %}"><small>{% trans "Forgot Password?" %}</small></a>
  {% endif %}
</form>

{% if enable_sso %}
<br>
<h4 class="text-center">{% trans 'or use SSO' %}</h4>
<div>
  {% include "socialaccount/snippets/provider_list.html" with process="login" %}
</div>
{% include "socialaccount/snippets/login_extra.html" %}
{% endif %}

{% endblock %}
