{% extends "base.html" %}

{% load i18n %}
{% load bootstrap_toolkit %}
{% load django_bootstrap_breadcrumbs %}
{% load common_tags %}

{% block title %}{% trans "Change your password" %}{% endblock %}

{% block breadcrumbs %}
    {{ block.super }}
    {% breadcrumb 'Account' None %}
    {% breadcrumb 'Password change' 'password_change' %}
{% endblock %}

{% block content %}
    {% if READONLY_MODE %}
        {% include 'readonly_mode.html' %}
    {% else %}
        <h1>{% trans "Request a secure link to change your password" %}</h1>

        {% if not request.user.userprofile.detected_insecure_password %}
            <p>
                {% blocktrans trimmed %}
                    Your password is already secure, and you can change it at any time. You do not need to request a
                    secure link to change your password.
                {% endblocktrans %}
            </p>
        {% else %}
            {% if 'sent' in request.GET %}
                <p class="alert alert-success">
                    {% blocktrans trimmed %}
                        We have emailed you with a secure link to change your password. Please check your inbox
                        and follow the instructions in the email.
                    {% endblocktrans %}
                </p>
            {% else %}
                <p>
                    {% blocktrans trimmed %}
                        On your last login attempt, we detected that your password is not secure. To prevent account
                        theft, we require that you confirm your email address before changing your password.
                    {% endblocktrans %}
                </p>

                <form class="form-horizontal" method="post" action="">{% csrf_token %}
                    {{ form|as_bootstrap }}
                    <div class="form-actions">
                        <button class="btn btn-primary btn-block-mobile {% button_loading_class %}" type="submit">
                            {% trans 'Request secure link' %}
                            {% button_loading_indicator %}
                        </button>
                    </div>
                </form>
            {% endif %}
        {% endif %}
    {% endif %}
{% endblock %}
