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

{% load i18n dashub %}
{% get_dashub_settings request as dashub_settings %}

{% block content %}
    <form action="{{ app_path }}" method="post" class="theme-form">
        {% csrf_token %}
        {% if user.is_authenticated %}
            <p class="errornote">
            <div class="callout callout-danger">
                <p>
                    {% blocktrans trimmed %}
                        You are authenticated as {{ username }}, but are not authorized to
                        access this page. Would you like to login to a different account?
                    {% endblocktrans %}
                </p>
            </div>
            </p>
        {% endif %}
        {% if form.errors %}
            {% if form.username.errors %}
                <div class="callout callout-danger">
                    <p>{{ form.username.label }}: {{ form.username.errors|join:', ' }}</p>
                </div>
            {% endif %}
            {% if form.password.errors %}
                <div class="callout callout-danger">
                    <p>{{ form.password.label }}: {{ form.password.errors|join:', ' }}</p>
                </div>
            {% endif %}
            {% if form.non_field_errors %}
                <div class="callout callout-danger">
                    {% for error in form.non_field_errors %}
                        <p>{{ error }}</p>
                    {% endfor %}
                </div>
            {% endif %}
        {% endif %}

        <h4>Sign in to account </h4>
        <p>Enter your email &amp; password to login</p>

        <div class="form-group">
            <label class="col-form-label">{{ form.username.label }}</label>
            <input class="form-control" type="text" required name="username" placeholder="{{ form.username.label }}">
        </div>

        <div class="form-group">
            <label class="col-form-label">Password </label>
            <div class="form-input position-relative">
                <input class="form-control" type="password" name="password" required
                       placeholder="*********">
                <div class="show-hide"><span class="show"></span></div>
            </div>
        </div>

        <div class="row mt-3">
            <div class="col-12">
                <button type="submit" class="btn w-100 btn-primary btn-block">
                    {% trans "Sign in" %}
                </button>
            </div>
        </div>
    </form>
{% endblock %}
