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

  This file is part of Invenio.
  Copyright (C) 2015-2020 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 page_body %}
<div class="ui padded segments big form">
  <div class="ui segment padded">

    {%- block form_header %}
      <h3 class="ui reset-password header">{{_('Reset Password')}}</h3>
    {%- endblock form_header %}

    {%- if messages %}
      {%- for category, message in messages %}
      <p>{{ message }}</p>
      {%- endfor %}
    {%- else %}
      <p class="">
        {{_('Enter your email address below and we will send you a link to reset your password.')}}
      </p>
      {%- with form = forgot_password_form %}
      <form action="{{ url_for_security('forgot_password') }}" method="POST" name="forgot_password_form">
        {{ form.hidden_tag() }}
        {{ render_field(form.email, icon="user icon", autofocus=True, errormsg='email' in form.errors) }}
        <button type="submit" class="ui fluid large submit primary button">{{_('Reset Password')}}</button>
      </form>
      {%- endwith %}
    {%- endif %}

  </div>

  {%- if current_user.is_anonymous %}
    <div class="ui primary segment padded 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 %}
    </div>
  {%- endif %}

</div>
{% endblock page_body %}
