{% 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: ``settings`` fill the server fields, a ``provider`` names the candidate's, ``suffix`` keeps ids apart, ``error`` shows under the password why the last try was refused. #} {% macro connect_form(email, settings, suffix="", provider=None, password_label="Password", hint=None, folded=True, primary=True, display_name="", error=None) %} {% set ids = "-" ~ suffix if suffix else "" %}
{{ csrf_field() }} {% if provider %}{% endif %}
{% if not provider %}
{% endif %}
{% if error %}{{ error }}{% endif %} {% if hint %}{{ hint }}{% endif %}
{% if folded %}
Servers {{ connection_fields(settings, security, suffix=suffix, protocol=provider) }}
{% else %}
{{ connection_fields(settings, security, suffix=suffix, protocol=provider) }}
{% 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, provider=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, suffix=loop.index, provider=candidate.provider.value, 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 %} {% if "imap" in offers or "pop3" in offers %}

Set up by hand

{% if not usable and not sign_ins %}

No way to connect {{ discovery.email }} over JMAP, IMAP or POP3 was found. Enter your provider's servers.

{% endif %} {{ connect_form(discovery.email, {}, suffix="hand", folded=False, primary=not usable and not sign_ins) }}
{% endif %} {% if "jmap" in offers %}

Set up a JMAP server by hand

{{ connect_form(discovery.email, {}, suffix="jmap", provider="jmap", password_label="Password or API token", folded=False, primary=False, hint="Choose below which one it is. Tried against the server first, then stored encrypted.") }}
{% endif %}

What the sources answered

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