{#
Copyright 2024, 2025 New Vector Ltd.
Copyright 2021-2024 The Matrix.org Foundation C.I.C.

SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
-#}

{% extends "base.html" %}

{% block content %}
  <header class="page-heading">
    <div class="icon">
      {{ icon.lock() }}
    </div>

    <div class="header">
      <h1 class="title">Hi {{ current_session.user.username }}</h1>
      <p class="text">To continue, please verify it's you:</p>
    </div>
  </header>

  <main class="flex flex-col gap-6">
    <form method="POST" class="cpd-form-root">
      <input type="hidden" name="csrf" value="{{ csrf_token }}" />
      {# TODO: errors #}

      {% call(f) field.field(label=_("common.password"), name="password", form_state=form) %}
        <input {{ field.attributes(f) }} class="cpd-text-control" type="password" autocomplete="password" required />
      {% endcall %}

      {{ button.button(text=_("action.continue")) }}
    </form>

    {% if next and next.kind == "continue_authorization_grant" %}
      {{ back_to_client.link(
        text="Cancel",
        destructive=True,
        uri=next.grant.redirect_uri,
        mode=next.grant.response_mode,
        params=dict(error="access_denied", state=next.grant.state)
      ) }}
    {% endif %}

    <div class="flex gap-1 justify-center items-center">
      <p class="cpd-text-secondary cpd-text-body-md-regular">
        Not {{ current_session.user.username }}?
      </p>

      {% set post_logout_action = next["params"] | default({}) %}
      {{ logout.button(text="Sign out", csrf_token=csrf_token, post_logout_action=post_logout_action, as_link=true) }}
    </div>
  </main>
{% endblock content %}
