{# -*- coding: utf-8 -*-

  This file is part of Invenio.
  Copyright (C) 2015-2018 CERN.

  Invenio is free software; you can redistribute it and/or modify it
  under the terms of the MIT License; see LICENSE file for more details.
#}

{%- extends config.ACCOUNTS_COVER_TEMPLATE %}

{% from "invenio_accounts/_macros.html" import render_field, form_errors %}
{%- set messages = get_flashed_messages(with_categories=true) -%}

{% block panel %}
{%- with form = reset_password_form %}
<div class="col-md-6 col-md-offset-3">
  <div class="panel panel-default">
    <div class="panel-body">
      <h3 class="text-center panel-free-title">{{_('Reset Password')}}</h3>
      {%- if messages %}
      {%- for category, message in messages %}
        <p>{{ message }}</p>
      {%- endfor %}
      {%- else %}
      <form action="{{ url_for_security('reset_password', token=reset_password_token) }}" method="POST" name="reset_password_form">
        {{ form.hidden_tag() }}
        {{ render_field(reset_password_form.password, icon="glyphicon glyphicon-user", autofocus=True) }}
        {{ render_field(reset_password_form.password_confirm, icon="glyphicon glyphicon-user", autofocus=True) }}
        <button type="submit" class="btn btn-primary btn-lg btn-block">{{_('Reset Password')}}</button>
      </form>
      {%- endif %}
    </div>

    {# contents of this if-block can be always shown after mattupstate/flask-security#291 is released. #}
    {%- if current_user.is_anonymous %}
    <div class="panel-footer text-center">
        <h4 class="text-muted"><a href="{{url_for('security.login')}}">{{_('Log in')}}</a>{% if security.registerable %} {{_('or')}} <a href="{{url_for('security.register')}}">{{_('Sign up')}}</a>{% endif %}</h4>
    </div>
    {%- endif %}
  </div>
</div>
{%- endwith %}
{% endblock panel %}
