{% extends 'auth/master.twig' %}
{% from 'macros.twig' import container_title %}
{% from '_layout/input.twig' import input_hidden, input_csrf, input_text %}

{% set title = 'Resetting password' %}

{% block content %}
    <form class="container auth__container auth__password" method="post" action="{{ url('auth-reset') }}">
        {{ container_title('<i class="fas fa-user-lock fa-fw"></i> Resetting password for ' ~ password_user.name) }}

        {{ input_hidden('reset[user]', password_user.id) }}
        {{ input_csrf() }}

        {% if password_notices|length > 0 %}
            <div class="warning auth__warning">
                <div class="warning__content">
                    {% for notice in password_notices %}
                        <p class="auth__warning__paragraph">{{ notice }}</p>
                    {% endfor %}
                </div>
            </div>
        {% else %}
            <div class="warning auth__warning auth__warning--welcome">
                <div class="warning__content">
                    <p class="auth__warning__paragraph">A verification code should've been sent to your e-mail address.</p>
                </div>
            </div>
        {% endif %}

        {% if password_verification|length == 12 %}
            {{ input_hidden('reset[verification]', password_verification) }}
        {% else %}
            <label class="auth__label">
                <div class="auth__label__text">
                   Verification Code
                </div>
                <div class="auth__label__value">
                    {{ input_text('reset[verification]', 'input__text--monospace auth__label__input', '', 'text', '', true, {'maxlength':12}, 1) }}
                </div>
            </label>
        {% endif %}

        <label class="auth__label">
            <div class="auth__label__text">
               New Password
            </div>
            <div class="auth__label__value">
                {{ input_text('reset[password][new]', 'auth__label__input', '', 'password', '', true, null, 2) }}
            </div>
        </label>

        <label class="auth__label">
            <div class="auth__label__text">
               Confirm Password
            </div>
            <div class="auth__label__value">
                {{ input_text('reset[password][confirm]', 'auth__label__input', '', 'password', '', true, null, 3) }}
            </div>
        </label>

        <div class="auth__buttons">
            <button class="input__button auth__buttons__button" tabindex="4">Change Password</button>
            <a href="{{ url('auth-login') }}" class="input__button auth__buttons__button auth__buttons__button--minor" tabindex="5">Log in</a>
        </div>
    </div>
{% endblock %}
