{% extends "login/layout/sidebar-layout.html.twig" %}

{% import "common/macro_flashes.html.twig" as macro_flashes %}
{% import "login/common/macros.html.twig" as auth_macro %}

{% block title %}
    {{ "Renew password" | trans }}
{% endblock %}

{% block sidebar %}
    <div class="well-large sidebar-block">
        <div class="row-fluid">
            <div class="span12 authentication-sidebar-title">
                <div class="text-title">
                    {{ "Choose a new password" | trans }}
                </div>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12">
                {{ macro_flashes.flashes() }}
                <form
                    novalidate
                    name="passwordChangeForm"
                    method="POST"
                    action="{{ path('reset_password') }}"
                >
                    <div class="row-fluid">
                        <div class="span12">
                            {{ form_errors(form) }}
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12">
                            {{ auth_macro.fieldInput(form.oldPassword, "passwordChangeForm", 'fa fa-lock') }}
                        </div>
                    </div>

                    {{ auth_macro.repeatedInput(form.password, "passwordChangeForm", 'fa fa-lock') }}

                    {{ form_rest(form) }}
                    <div class="row-fluid">
                        <div class="span12">
                            <button type="submit" class="btn btn-success btn-trigger ">
                                {{ "Save" | trans }}
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
{% endblock %}

{% block scripts %}
    {{ parent() }}
    <script>
        authenticateApp.bootstrap({
            state: 'changePassword'
        });
        // cross-browser asynchronous script loading for zxcvbn.
        // adapted from http://friendlybit.com/js/lazy-loading-asyncronous-javascript/
        (function() {

            var ZXCVBN_SRC = 'assets/vendors/zxcvbn/zxcvbn{% if not app.debug %}.min{% endif %}.js';

            var async_load = function() {
                var first, s;
                s = document.createElement('script');
                s.src = ZXCVBN_SRC;
                s.type = 'text/javascript';
                s.async = true;
                first = document.getElementsByTagName('script')[0];
                return first.parentNode.insertBefore(s, first);
            };

            if (window.attachEvent != null) {
                window.attachEvent('onload', async_load);
            } else {
                window.addEventListener('load', async_load, false);
            }

        }).call(this);
    </script>
{% endblock %}
