{% extends "base.html" %}

{% block title %} | Change password{% endblock %}

{% block main %}
        <div class="page-header">
            <div class="container">
                <h1 class="smaller"><a href="{% url 'admin:userprofile'%}">Your profile</a></h1>
            </div>
        </div>

        <div class="container">
            <div class="row">
                <div class="col-sm-6 col-sm-offset-3">
                    <h3 class="header">Change password</h3>
                    {% include 'snippets/messages.html' %}
                    {% if form.errors %}
                    <div class="alert alert-danger">
                        <strong>We were not able to change the password: </strong>
                        {% if form.oldpassword.errors %}<ul><li>The current password you entered was wrong.</li></ul>{% endif %}
                        {{ form.password1.errors }}
                        {{ form.password2.errors }}
                    </div>
                    {% endif %}

                    <form role="form" action="{% url 'account_change_password' %}" method="POST" novalidate>
                        {% csrf_token %}
                        <div class="form-group">
                            <label for="oldpassword">Old password</label>
                            <input type="password" class="form-control input-lg" name="oldpassword" id="oldpassword" required>
                        </div>
                        <div class="form-group">
                            <label for="password1">New password</label>
                            <input type="password" class="form-control input-lg" name="password1" id="password1" required>
                        </div>
                        <div class="form-group">
                            <label for="password2">Repeat new password</label>
                            <input type="password" class="form-control input-lg" name="password2" id="password2" required>
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-primary">Change my password</button>
                            <a href="{% url 'account_reset_password' %}" class="btn btn-link">Forgot password?</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
{% endblock %}

{% block libraries %}
            <script src="/static/js/admin.ui.forms.validate.js"></script>
{% endblock %}
