Multi-server login: choose your server (Mastodon-style, no key needed) #712

Merged
raisondetredev merged 2 commits from refs/pull/712/head into main 2026-07-01 14:07:52 +02:00
raisondetredev commented 2026-07-01 14:00:27 +02:00 (Migrated from codeberg.org)

Adds a "choose your server" step to the auth flows so a learner logs in by
picking/typing a server domain instead of the app silently defaulting to the
cloud project. Companion infra PR (serves the discovery document):
https://codeberg.org/project-halkyon/halkyon-infra/compare/main...instance-discovery-endpoint

Builds on the already-merged native registry-persistence fix.

What changes

  • Two-step sign-in / sign-up / add-account: first choose a server — a typed
    domain (discovered via /.well-known/halkyon-learn.json, so no publishable
    key is entered
    ) or a one-tap of the compiled-in default — then credentials.
  • InstanceDiscoveryService resolves a domain → {supabaseUrl, anonKey}
    from the public well-known document (the Supabase analogue of Mastodon's
    /api/v1/instance; the anon key is publishable). Typed errors
    (invalidDomain / network / notFound / malformed) drive the UI messages.
  • Unified account adoption (resolveSignedInRecord): the first login (or a
    re-login of the same server+user) adopts the primary slot — keeping the legacy
    DB + session key, so an upgrading user's data is reused and no placeholder is
    left behind — while any other (server, user) becomes its own isolated account.
  • Activation-generation counter folded into activeContextKey: re-pointing
    the primary slot keeps accountId='primary', so without this the router
    wouldn't rebuild and a fresh sign-in wouldn't navigate past the login screen.
  • Removes the now-unused AuthBloc + sign-in/up forms (sign-out already calls
    AuthRepository.signOut directly); screens drive AccountManager.

Testing

flutter analyze clean on touched files. 65 auth + multi_account tests pass
(new: 5 sign-in, 4 sign-up, 7 discovery, 6 account-adoption). Screen tests use a
NoSplash theme to avoid the pre-existing ink_sparkle.frag shader flake.

Follow-ups (not in this PR)

  • Release default still points at cloud; the picker supersedes it (flip
    .env/.env.build to learn.halkyon.li if you'd rather change the default).
  • The infra PR's anonKey must be filled in and the proxy route added on the
    server.
Adds a "choose your server" step to the auth flows so a learner logs in by picking/typing a server domain instead of the app silently defaulting to the cloud project. Companion infra PR (serves the discovery document): https://codeberg.org/project-halkyon/halkyon-infra/compare/main...instance-discovery-endpoint Builds on the already-merged native registry-persistence fix. ## What changes - **Two-step sign-in / sign-up / add-account**: first choose a server — a typed domain (discovered via `/.well-known/halkyon-learn.json`, so **no publishable key is entered**) or a one-tap of the compiled-in default — then credentials. - **`InstanceDiscoveryService`** resolves a domain → `{supabaseUrl, anonKey}` from the public well-known document (the Supabase analogue of Mastodon's `/api/v1/instance`; the anon key is publishable). Typed errors (invalidDomain / network / notFound / malformed) drive the UI messages. - **Unified account adoption** (`resolveSignedInRecord`): the first login (or a re-login of the same server+user) adopts the primary slot — keeping the legacy DB + session key, so an upgrading user's data is reused and no placeholder is left behind — while any other (server, user) becomes its own isolated account. - **Activation-generation counter** folded into `activeContextKey`: re-pointing the primary slot keeps `accountId='primary'`, so without this the router wouldn't rebuild and a fresh sign-in wouldn't navigate past the login screen. - Removes the now-unused `AuthBloc` + sign-in/up forms (sign-out already calls `AuthRepository.signOut` directly); screens drive `AccountManager`. ## Testing `flutter analyze` clean on touched files. 65 auth + multi_account tests pass (new: 5 sign-in, 4 sign-up, 7 discovery, 6 account-adoption). Screen tests use a `NoSplash` theme to avoid the pre-existing `ink_sparkle.frag` shader flake. ## Follow-ups (not in this PR) - Release default still points at cloud; the picker supersedes it (flip `.env/.env.build` to `learn.halkyon.li` if you'd rather change the default). - The infra PR's `anonKey` must be filled in and the proxy route added on the server.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
project-halkyon/halkyon-learn!712
No description provided.