{% extends "base.html" %}

{% block title %}Change Password{% endblock %}

{% block content %}
    <h1>Change Password</h1>

    {% if error %}
        <p class="error">{{ error }}</p>
    {% endif %}

    <p class="hint">Logged in as {{ username }}.</p>

    <form method="POST">
        <label>Current Password</label>
        <input type="password" name="current_password" required />
        <label>New Password ({{ min_password_length }} characters minimum)</label>
        <input type="password" name="new_password" minlength={{ min_password_length }} required />
        <label>Confirm New Password</label>
        <input type="password" name="confirm_new_password" minlength={{ min_password_length }} required />

        {% if csrftoken and csrf_cookie_name %}
            <input type="hidden" name="{{ csrf_cookie_name }}" value="{{ csrftoken }}" />
        {% endif %}

        <!-- This tells the endpoint to returns a HTML reponse if login fails. -->
        <input type="hidden" value="html" name="format" />

        <p class="hint">If successful, you will be redirected to the login page to confirm your new credentials.</p>

        <button>Change Password</button>
    </form>
{% endblock %}
