{% extends 'base.html' %}

{% block content %}

<div class="d-flex justify-content-center flex-column align-items-center">
    <h1 class="text-center mb-5">Вход</h1>

    {% for error in form.non_field_errors %}
        <div class="alert alert-danger">{{ error }}</div>
    {% endfor %}

    <form action="{% url 'login' %}" method="post" class="text-center">
        {% csrf_token %}

        <div class="mb-3">
            <label for="username" class="form-label">Username</label>
            <input type="text" class="form-control" id="username" aria-describedby="usernameHelp" name="username">
            <div id="usernameHelp" class="form-text">We'll never share your username with anyone else.</div>
        </div>
        {% if form.username.errors %}
            {% for error in form.username.errors %}
                <div class="alert alert-danger">{{ error }}</div>
            {% endfor %}
        {% endif %}

        <div class="mb-3">
            <label for="password" class="form-label">Password</label>
            <input type="password" class="form-control" id="password" name="password" required>
        </div>
        {% if form.password.errors %}
            {% for error in form.password.errors %}
                <div class="alert alert-danger">{{ error }}</div>
            {% endfor %}
        {% endif %}

        <button type="submit" class="btn btn-primary">Submit</button>
    </form>

    <div class="mt-5">
        Don't have account?
        <a class="" href="{% url 'register' %}?next={{ request.get_full_path }}">Register</a>
    </div>

</div>

{% endblock %}
