{% extends "base.html" %} {% from "components/ui.html" import breadcrumb, csrf_field with context %} {% from "components/connection.html" import connection_fields %} {% block title %}Connect an account ยท {{ APP_NAME }}{% endblock %} {% block heading %}Connect an account{% endblock %} {% block subheading %}{{ breadcrumb([("Accounts", "/ui/accounts"), ("Connect an account", None)]) }}{% endblock %} {% block content %} {# Connect with a password: ``connection`` describes the kind of account, ``settings`` fill its fields, ``suffix`` keeps ids apart, ``error`` shows under the password why the last try was refused. #} {% macro connect_form(email, settings, connection, suffix="", password_label=None, hint=None, folded=True, primary=True, display_name="", error=None) %} {% set ids = "-" ~ suffix if suffix else "" %}
{{ csrf_field() }}
{% if error %}{{ error }}{% endif %} {% if hint %}{{ hint }}{% endif %}
{% if folded %}
Servers {{ connection_fields(connection, settings, suffix=suffix) }}
{% else %}
{{ connection_fields(connection, settings, suffix=suffix) }}
{% endif %}
Connect
{% endmacro %} {# Two ways: in this browser, sent back to this service, or with a code entered at the provider on any device. The first only where the provider can send the browser back here (``in_browser``), the second only where it offers codes (``with_code``). #} {% macro sign_in_form(provider, hint="") %} {% if provider in in_browser %}
{{ csrf_field() }}
{% endif %} {% if provider in with_code %}
{{ csrf_field() }} Sign in {% if provider in in_browser %}with a code{% else %}with {{ provider | signs_in_at }} and a code{% endif %} {% endif %} {% endmacro %} {% macro ways_hint(provider) %}{% if provider in in_browser and provider in with_code %}In the browser, the provider sends you back to this service. Or sign in with a code on any device.{% elif provider in in_browser %}In the browser, the provider sends you back to this service.{% else %}{{ provider | signs_in_at }} sends a browser back to this service only at localhost, so you sign in with a code on any device.{% endif %}{% endmacro %}

1. The address

{{ csrf_field() }}

Asks public sources how the address's provider is reached. No password leaves this service.

{% if retry %}

2. Your servers

The provider refused. Nothing was stored.
{{ connect_form(email, retry.settings, connections[retry.provider], password_label="API token" if retry.settings.get("auth") == "token" else "Password", folded=False, display_name=retry.display_name, error=retry.error, hint="Tried against the provider first, then stored encrypted. Never shown again.") }}
{% endif %} {% if discovery %} {% for hint in discovery.hints %}
{{ hint.text }}{% if hint.url %} More{% endif %}
{% endfor %}

2. How to connect {{ discovery.email }}

{% for candidate in sign_ins %}

{{ candidate.name or discovery.domain }}

found by {{ candidate.source.value }} {% if loop.first %}recommended{% endif %}
{{ sign_in_form(candidate.oauth_provider, discovery.email) }} No password is needed. {{ candidate.oauth_provider | signs_in_at }} asks you, and this service keeps only a token it can renew. {{ ways_hint(candidate.oauth_provider) }}
{% endfor %} {% for candidate in usable %}

{{ candidate.name or discovery.domain }}

found by {{ candidate.source.value }} {% if loop.first and not sign_ins %}recommended{% endif %} {% if candidate.confirmed %}trusted source{% else %}check these servers{% endif %}
{% if not candidate.confirmed %}
This answer does not come from the domain itself or from a known provider. Connect only if the servers below are really your provider's.
{% endif %} {% for hint in candidate.hints %}

{{ hint.text }}{% if hint.url %} More{% endif %}

{% endfor %} {{ connect_form(discovery.email, candidate.settings, connections[candidate.provider.value], suffix=loop.index, password_label={"app_password": "App password", "api_token": "API token"}.get(candidate.credential.value, "Password"), hint="Tried against the provider first, then stored encrypted. Never shown again.") }}
{% endfor %} {% if oauth_providers and not sign_ins %}

Sign in with your provider

if the address is at one of these
{% for provider in oauth_providers %}{{ sign_in_form(provider, discovery.email) }}{{ ways_hint(provider) }}{% endfor %}
{% endif %} {% set nothing_found = not usable and not sign_ins %} {% for connection in by_hand %}

Set up {{ connection.name }} by hand

{% if connection.about %}{{ connection.about }}{% endif %}
{% if nothing_found and loop.first %}

No way to connect {{ discovery.email }} was found. Enter your provider's servers.

{% endif %} {{ connect_form(discovery.email, {}, connection, suffix="hand-" ~ connection.kind, folded=False, primary=nothing_found and loop.first, hint="Tried against the server first, then stored encrypted. Never shown again.") }}
{% endfor %}

What the sources answered

{% for report in discovery.sources %} {% endfor %}
{{ report.source.value }}{{ report.outcome.value }}{{ report.message | or_missing }}
{% endif %} {% endblock %}