{% extends "sentry/bases/auth.html" %}

{% load crispy_forms_tags %}
{% load i18n %}
{% load sentry_helpers %}

{% block title %}{% trans "Confirm Identity" %} | {{ block.super }}{% endblock %}

{% block auth_main %}
  {% if existing_user %}
    <div class="sso-link">
      <span class="avatar">
        {% letter_avatar_svg existing_user.get_display_name existing_user.get_label %}
        <img src="{% gravatar_url existing_user.email size 36 default 'blank' %}">
      </span>
      <span class="icon-arrow-right"></span>
      <span class="icon-arrow-left"></span>
      <span class="avatar">
        {% letter_avatar_svg identity_display_name identity_identifier %}
        <img src="{% gravatar_url identity.email size 36 default 'blank' %}" class="avatar">
      </span>
    </div>

    <form class="form-stacked" action="" method="post" autocomplete="off">
      {% csrf_token %}

      <div class="align-center">
        <p>We found an existing account for {{ identity.email }}.</p>
        <p>Please confirm your credentials:</p>
      </div>

      {{ login_form|as_crispy_errors }}

      {% for field in login_form %}
        {{ field|as_crispy_field }}
      {% endfor %}

      <fieldset class="form-actions">
        <button type="submit" class="btn btn-primary" name="op" value="login">{% trans "Login" %}</button>
        <a class="pull-right" style="margin-top: 9px" href="{% url 'sentry-account-recover' %}">{% trans "Lost your password?" %}</a>
      </fieldset>
    </form>
  {% else %}
    <form class="form-stacked" action="" method="post">
      {% csrf_token %}

      <div class="sso-link">
        <span class="avatar">
          {% letter_avatar_svg identity_display_name identity_identifier %}
          <img src="{% gravatar_url identity.email size 36 default 'blank' %}" class="avatar">
        </span>
      </div>

      <div class="align-center">
        <p>We've identified you as {{ identity.email }}.</p>

        <p>We'll go ahead and create a new account for you with this email address.</p>

        <p><button class="btn btn-primary" type="submit" name="op" value="newuser">Continue</button></p>
      </div>
    </form>
  {% endif %}
{% endblock %}
