{% extends "_layout.html.j2" %}

{%- block title -%}
Reset your password
{%- endblock -%}

{%- block content -%}
<div class="panel narrow">
    <h1>Reset your password</h1>
    {% match body %}
        {% when ResetPasswordValidateBody::ValidationPending { session_id, client_secret, validation_error } %}
            <p>
                A message has been sent to your email address with a validation link.
                To finish resetting your password, click the link and then return to this page.
                If you do not receive the email:
                <ul>
                    <li>Check your spam filter.</li>
                    <li>Your Matrix account may not be associated with an email address. Contact your homeserver's
                    administrator for assistance.</li>
                </ul>
            </p>
            {% if validation_error %}
                <small class="error">Validation failed. Have you clicked the link in the email that was sent to you?</small>
            {% endif %}
            <form method="get" action="validate">
                <input type="hidden" name="session_id" value="{{ session_id }}">
                <input type="hidden" name="client_secret" value="{{ client_secret }}">
                <button type="submit">Continue</button>
            </form>
        {% when ResetPasswordValidateBody::ValidationSuccess { user_card, form } %}
            {{ user_card }}
            {{ form }}
        {% when ResetPasswordValidateBody::ResetSuccess { user_card } %}
            {{ user_card }}
            <p>Your password has been reset successfully. <a href="{{ crate::ROUTE_PREFIX }}/account/login">Return to login</a></p>
    {% endmatch %}
</div>
{%- endblock -%}
