{% extends "base.html" %}
{% macro oauth_button() %}
<a class="btn w-100" href="/auth/oauth/start?next={{ next | urlencode }}">
  {% if oauth_provider | lower == "github" %}
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false" class="icon text-github">
    <path d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" />
  </svg>
  {% elif oauth_provider | lower == "google" %}
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false" class="icon">
    <path d="M20.945 11a9 9 0 1 1 -3.284 -5.997l-2.655 2.392a5.5 5.5 0 1 0 2.119 6.605h-4.125v-3h7.945z" />
  </svg>
  {% endif %}
  Login with {{ oauth_provider | e }}
</a>
{% endmacro %}
{% block body_attrs %} class="theme-dark-auto"{% endblock %}
{% block head %}
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
{% endblock %}
{% block body %}
<main class="page page-center" id="content">
  <div class="container container-tight py-4">
    <div class="text-center mb-4">
      <a href="/" aria-label="{{ site_name | default('PyGitWeb') }}" class="navbar-brand">
        <img src="/static/logo.svg" height="120" alt="" class="navbar-brand-image">
      </a>
    </div>
    <div class="card card-md">
      <div class="card-body">
        <h1 class="h2 text-center mb-4">Login to your account</h1>
        {% if error %}
        <div class="alert alert-danger" role="alert">{{ error }}</div>
        {% endif %}
        {% if local_available %}
        <form method="post" action="/login" autocomplete="off" novalidate>
          <input type="hidden" name="next" value="{{ next }}">
          <div class="mb-3">
            <label class="form-label" for="login_username">Username</label>
            <input type="text" class="form-control" id="login_username" name="username" placeholder="Your username" required autocomplete="username" autofocus>
          </div>
          <div class="mb-2">
            <label class="form-label" for="login_password">Password</label>
            <div class="input-group input-group-flat">
              <input type="password" class="form-control" id="login_password" name="password" placeholder="Your password" required autocomplete="current-password">
              <span class="input-group-text">
                <button type="button" class="link-secondary input-group-link border-0 bg-transparent p-0" title="Show password" aria-label="Show password" aria-pressed="false" data-password-toggle="login_password">
                  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false" class="icon icon-toggle-show">
                    <path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
                    <path d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" />
                  </svg>
                  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false" class="icon icon-toggle-hide d-none">
                    <path d="M10.585 10.587a2 2 0 0 0 2.829 2.828" />
                    <path d="M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87" />
                    <path d="M3 3l18 18" />
                  </svg>
                </button>
              </span>
            </div>
          </div>
          <div class="form-footer">
            <button type="submit" class="btn btn-primary w-100">Sign in</button>
          </div>
        </form>
        {% elif oauth_available %}
        <div class="row">
          <div class="col">{{ oauth_button() }}</div>
        </div>
        {% else %}
        <p class="text-secondary text-center mb-0">No sign-in methods are configured.</p>
        {% endif %}
      </div>
      {% if oauth_available and local_available %}
      <div class="hr-text">or</div>
      <div class="card-body">
        <div class="row">
          <div class="col">{{ oauth_button() }}</div>
        </div>
      </div>
      {% endif %}
    </div>
    {% if local_available %}
    {% endif %}
  </div>
</main>
{% endblock %}
{% block scripts %}
<script defer src="/static/login.js"></script>
{% endblock %}