{% extends "security/base.html" %}
{% from "security/_macros.html" import render_field_with_errors, render_field, render_field_errors %}

{% block content %}
    {% include "security/_messages.html" %}
    <h1>{{ _fsdomain("Sign In") }}</h1>
      <form action="{{ url_for_security("us_signin") }}" method="POST"
          name="us_signin_form">
      {{ us_signin_form.hidden_tag() }}
      {{ render_field_with_errors(us_signin_form.identity) }}
      {{ render_field_with_errors(us_signin_form.passcode) }}
      {{ render_field_with_errors(us_signin_form.remember) }}
      {{ render_field(us_signin_form.submit) }}
      {% if code_methods %}
        <h4>{{  _fsdomain("Request one-time code be sent") }}</h4>
        {% for subfield in us_signin_form.chosen_method %}
          {% if subfield.data in code_methods %}
            {{ render_field_with_errors(subfield) }}
          {% endif %}
        {% endfor %}
        {{ render_field_errors(us_signin_form.chosen_method) }}
        {% if code_sent %}
          <p>{{ _fsdomain("Code has been sent") }}
        {% endif %}
        {{ render_field(us_signin_form.submit_send_code, formaction=url_for_security('us_signin_send_code')) }}
      {% endif %}
      </form>
  {% include "security/_menu.html" %}
{% endblock %}
