Members choose: connect's Admit, the choose page, IsHomeDerived (Oficina ID native slice A)
Human
Prompt
Wire the connect half of slice A into Docs: Config.Admit, the choose page route, IsHomeDerived adoption (spec 2026-11-14 §7, §8).
From this commit's own message. The prompt ledger has no entries for it — which is what a squashed, rebased or amended commit looks like, and what every commit looks like in a repo without a ledger.
Summary
Repins home/connect and home/handoff to Home branch feat/oficina-id-native-connect (354c7e9; repin to main after it lands). Team mode wires connect's new Admit hook to Runtime.AdmitUnlinked, so a roster member with no account here gets 'Welcome to the team' at /account/home/choose (Connect my existing account / I'm new here) instead of an automatic Home-only principal; non-members and an unavailable roster are unchanged. Every Home-session check uses connect.IsHomeDerived, and the identity resolver refuses native and native-web sessions seven days after minting (connect.Expired).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 files changed,
+171
−22
go.mod+2 −2go.sum+4 −0implementation/team-mode-integration.md+2 −0internal/docs/auth.go+3 −2internal/docs/home_connect.go+36 −10internal/docs/home_render.go+20 −0internal/docs/identity.go+14 −4internal/docs/render.go+6 −0internal/docs/team_access.go+2 −1internal/docs/team_home_test.go+49 −0internal/docs/team_probe_test.go+1 −1internal/docs/team_router_test.go+27 −1internal/docs/views/home_link.html+5 −1
diff --git a/go.mod b/go.mod| index 96f71e2..ac86f45 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -5,9 +5,9 @@ go 1.26.5 |
| require ( |
| amadan.net/oficina/agent-access.git v0.0.0-20261024232549-8ed8ba826000 |
| amadan.net/oficina/estilo.git v0.0.0-20261111234914-39792ae278b0 |
| - amadan.net/oficina/home/connect v0.0.0-20261101223546-d82341cd9a0c |
| + amadan.net/oficina/home/connect v0.0.0-20261114100717-354c7e94835d |
| amadan.net/oficina/home/dashboard v0.0.0-20261024235511-baa2503c7064 |
| - amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 |
| + amadan.net/oficina/home/handoff v0.0.0-20261114100717-354c7e94835d |
| amadan.net/oficina/home/roster v0.0.0-20261030153823-602f5136f9af |
| amadan.net/oficina/home/teammode v0.0.0-20261030153823-602f5136f9af |
| amadan.net/oficina/suite v0.0.0-20261102002704-91affa14eae4 |
diff --git a/go.sum b/go.sum| index d7711ec..83f2327 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -4,10 +4,14 @@ amadan.net/oficina/estilo.git v0.0.0-20261111234914-39792ae278b0 h1:6xlOgfIuccF6 |
| amadan.net/oficina/estilo.git v0.0.0-20261111234914-39792ae278b0/go.mod h1:2UFIFrbTrhew8EFM0C94WmTo2OASM2pHEgT4jzeE/s8= |
| amadan.net/oficina/home/connect v0.0.0-20261101223546-d82341cd9a0c h1:6NOvTeDLlctihXkIa/FCr1np3N3N4oKB0YS9x8VSfxI= |
| amadan.net/oficina/home/connect v0.0.0-20261101223546-d82341cd9a0c/go.mod h1:ix81eFV87yE9f2SXiRuxYCVM4lAgTRC5YoQMiH3+TDk= |
| +amadan.net/oficina/home/connect v0.0.0-20261114100717-354c7e94835d h1:yPui8TO+0HQUMWJ9e7SCeNsFfsmCH6l/hy2Qb9Pd92o= |
| +amadan.net/oficina/home/connect v0.0.0-20261114100717-354c7e94835d/go.mod h1:J2yX/3VRGYEo1iBwknETQ1abAZE1sL0EQScFpgtfXso= |
| amadan.net/oficina/home/dashboard v0.0.0-20261024235511-baa2503c7064 h1:2YbDksZDxpY9khlhXmTeiM89yze7w2XfYSumtrzH4tc= |
| amadan.net/oficina/home/dashboard v0.0.0-20261024235511-baa2503c7064/go.mod h1:+7xsX+QyVFrKy5gDAGh+FZ5+75z4CibWTL0wl9DWAw0= |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 h1:RPKtyry/71i06o8L+gjAaUyexbmG56kO1YPs601URAM= |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k= |
| +amadan.net/oficina/home/handoff v0.0.0-20261114100717-354c7e94835d h1:NxLRnZvp1eHlUkBquKPdkaeaAUpWi9u2BmTj66luA+k= |
| +amadan.net/oficina/home/handoff v0.0.0-20261114100717-354c7e94835d/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k= |
| amadan.net/oficina/home/roster v0.0.0-20261030153823-602f5136f9af h1:YtDEq1YUm87/v6XtP6+V32g9U3KDvKos1SdXsnOxA6A= |
| amadan.net/oficina/home/roster v0.0.0-20261030153823-602f5136f9af/go.mod h1:gqshuXyDtFZUCYbhuZyV3Epc51pUcsLbpqAqiA5UiXg= |
| amadan.net/oficina/home/teammode v0.0.0-20261030153823-602f5136f9af h1:QsC+WKvYxiKipS3+J4D9YWRmKQ+cJJTevlH6kP8UVhA= |
diff --git a/implementation/team-mode-integration.md b/implementation/team-mode-integration.md| index 6b00e3c..de98f5a 100644 |
| --- a/implementation/team-mode-integration.md |
| +++ b/implementation/team-mode-integration.md |
| @@ -46,6 +46,8 @@ In TeamMode, the Home branch of identity resolution calls `principalstore.Resolv |
| The shared handoff still verifies/consumes the assertion before ordinary completion. Keep the fresh-link branch of `homeBridge.complete` distinct and unchanged in authority. For ordinary TeamMode completion, first resolve an existing principal. If an actual current browser session exists, resolve it read-only and require the same principal; refuse unknown/conflicting arrivals before allocating anything. For an unknown incoming identity with no current session, call `EnsureHome` only after the exact fresh roster callback succeeds. No address matching, EnsurePerson fallback or account merge exists. A concurrent local-link winner causes refusal/retry, not an invented principal. |
| +**Amended 2026-11-14 (Home spec `2026-11-14-oficina-id-native.md` §8, Paul's ruling "members choose").** Ordinary completion no longer allocates. For an unknown incoming identity with no current session, connect asks `Config.Admit` (Docs' `homeRoutes.admit`, `Runtime.AdmitUnlinked`), which allocates nothing: a non-member gets the unchanged "unknown" answer, an undecidable roster 503, and a Member a single-use choice proof and `/account/home/choose`. Only "I'm new here" there (or a native exchange with `choice:"new"`) reaches `Unlinked` and so `EnsureHome`, after re-checking `Admit` and the link with no transaction open; "Connect my existing account" resumes local linking. A guest's local account therefore never blocks a member's first sign-in. The native app reaches the same decision through `POST /native/oficina-id` (connect `NativeExchange`), whose sessions carry `home-assertion-native` and end seven days after minting; every Home check uses `connect.IsHomeDerived`. |
| + |
| An existing resolved identity may receive an identity session without deriving document standing from it; its redirected request still undergoes roster/grant authorization. This permits a known linked guest to use an independent grant when team standing is absent. A new unknown Home identity cannot use an email grant because Home has supplied no email. Preserve the original assertion AuthTime, opaque subject, actual session-cookie duplicate checks and existing account-switch conflict checks. Allocation followed by failed session mint leaves one stable principal and requires a fresh handoff; replay is not revived. |
| `existingPerson` is no longer a general principal resolver: keep a strict local-person helper for dual-auth link binding and add a typed existing-principal helper for ordinary completion/current-session comparison. Home-only identity must not accidentally satisfy fresh local authentication. A Home-only principal cannot later be silently attached to another local account: the approved cross-table triggers refuse it. The local sign-in/link option stays available before first Home-only creation, and rollout pilots must link existing accounts before testing new-person entry. This stage does not promise account merging. |
diff --git a/internal/docs/auth.go b/internal/docs/auth.go| index 689eb69..e6d31f5 100644 |
| --- a/internal/docs/auth.go |
| +++ b/internal/docs/auth.go |
| @@ -16,6 +16,7 @@ import ( |
| "amadan.net/oficina/estilo.git/brand" |
| "amadan.net/oficina/estilo.git/chrome" |
| "amadan.net/oficina/estilo.git/sky" |
| + "amadan.net/oficina/home/connect" |
| rauth "amadan.net/rastrillo/rastrillo/auth" |
| "amadan.net/rastrillo/rastrillo/mail" |
| "amadan.net/rastrillo/rastrillo/sessions" |
| @@ -320,14 +321,14 @@ func requireAdmission(list allowlist, signinPath string) func(http.Handler) http |
| return *id.Actor.VerifiedAddress, true |
| } |
| s, ok := sessions.Current(r) |
| - return s.Subject, ok && s.Method != homeAssertionMethod |
| + return s.Subject, ok && !connect.IsHomeDerived(s.Method) |
| }) |
| return func(next http.Handler) http.Handler { |
| allowed := admission(next) |
| return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| // Missing adapter wiring fails closed even if an opaque subject happens |
| // to match an allowed address. It must not take the legacy fallback. |
| - if s, ok := sessions.Current(r); ok && s.Method == homeAssertionMethod { |
| + if s, ok := sessions.Current(r); ok && connect.IsHomeDerived(s.Method) { |
| if _, resolved := currentIdentity(r); !resolved { |
| refuseIdentity(w, r, signinPath) |
| return |
diff --git a/internal/docs/home_connect.go b/internal/docs/home_connect.go| index 7490a50..10925da 100644 |
| --- a/internal/docs/home_connect.go |
| +++ b/internal/docs/home_connect.go |
| @@ -104,9 +104,9 @@ func newHome(settings *homeSettings, origin string, db *sql.DB, store *Store, te |
| Render: h.render, |
| } |
| if team { |
| - // Team mode only. With both nil, connect refuses a Home subject with |
| - // no link as "unknown", as Docs always has outside team mode. |
| - cfg.HomeOnly, cfg.Unlinked = h.homeOnly, h.unlinked |
| + // Team mode only. With all three nil, connect refuses a Home subject |
| + // with no link as "unknown", as Docs always has outside team mode. |
| + cfg.Admit, cfg.HomeOnly, cfg.Unlinked = h.admit, h.homeOnly, h.unlinked |
| } |
| if h.bridge, err = connect.New(cfg); err != nil { |
| return nil, errHomeConfig |
| @@ -206,13 +206,34 @@ func (h *homeRoutes) homeOnly(ctx context.Context, issuer, subject string) (conn |
| return connect.Person{ID: p.ID}, nil |
| } |
| -// unlinked is connect's Unlinked, asked only when nobody is signed in here |
| -// and the subject has neither a link nor a Home-only principal. It creates |
| -// one only for a subject the roster says is a Member now, under a valid |
| -// lease (Runtime.AdmitUnlinked). principalstore's EnsureHome asks the same |
| -// gate again inside (RequireMembership), so the allocation condition holds |
| -// for every caller of EnsureHome, not only this one. A stranger is |
| +// admit is connect's Admit, the roster decision taken first (Home spec |
| +// 2026-11-14-oficina-id-native.md §8) for a subject with neither a link |
| +// nor a Home-only principal: Runtime.AdmitUnlinked, which allocates |
| +// nothing and never asks whether Docs has local accounts. A Member is |
| +// asked to choose (connect's choose page, or 409 natively); a stranger is |
| // connect's "unknown"; an undecidable roster is a 503. |
| +func (h *homeRoutes) admit(ctx context.Context, issuer, subject string) error { |
| + t := h.team |
| + if t == nil { |
| + return errTeamUnavailable |
| + } |
| + switch err := t.cache.AdmitUnlinked(ctx, issuer, subject); { |
| + case err == nil: |
| + return nil |
| + case errors.Is(err, teammode.ErrNotMember): |
| + return connect.ErrNoPerson |
| + } |
| + return errTeamUnavailable |
| +} |
| + |
| +// unlinked is connect's Unlinked, asked only after a Member chose "I'm new |
| +// here" with nobody signed in, for a subject with neither a link nor a |
| +// Home-only principal. It creates one only for a subject the roster says |
| +// is a Member now, under a valid lease (Runtime.AdmitUnlinked). |
| +// principalstore's EnsureHome asks the same gate again inside |
| +// (RequireMembership) and opens its own writer transaction, so the |
| +// allocation condition holds for every caller of EnsureHome, not only this |
| +// one. A stranger is connect's "unknown"; an undecidable roster is a 503. |
| func (h *homeRoutes) unlinked(ctx context.Context, issuer, subject string) (connect.Person, error) { |
| t := h.team |
| if t == nil { |
| @@ -259,6 +280,11 @@ func (h *homeRoutes) mountPublic(r chi.Router) { |
| r.Get(handoff.StartPath, h.bridge.Start) |
| r.Post(handoff.CallbackPath, h.bridge.Callback) |
| r.Get(handoff.FinishPath, h.bridge.Finish) |
| + // The member choice (team mode; connect answers 404 without the team |
| + // hooks): no session yet, so outside the session guards, and the POST |
| + // inside the app-wide CSRF check like any form. |
| + r.Get(connect.ChoosePath, h.bridge.ChoosePage) |
| + r.Post(connect.ChoosePath, h.bridge.ChoosePost) |
| } |
| // mountAccount is connecting an Oficina account: connect's link flow, |
| @@ -362,7 +388,7 @@ func (h *handlers) homeLinkLabel(r *http.Request) string { |
| return "" |
| } |
| id, ok := currentIdentity(r) |
| - if !ok || id.Session.Method == homeAssertionMethod || id.HomeSubject != "" { |
| + if !ok || connect.IsHomeDerived(id.Session.Method) || id.HomeSubject != "" { |
| return "" |
| } |
| if linked, err := h.homeLinked(r.Context(), id.Actor.PersonID); err != nil || linked { |
diff --git a/internal/docs/home_render.go b/internal/docs/home_render.go| index ea89c52..228a8a4 100644 |
| --- a/internal/docs/home_render.go |
| +++ b/internal/docs/home_render.go |
| @@ -6,6 +6,7 @@ import ( |
| "amadan.net/oficina/estilo.git/brand" |
| "amadan.net/oficina/estilo.git/chrome" |
| "amadan.net/oficina/estilo.git/sky" |
| + "amadan.net/oficina/home/connect" |
| "amadan.net/rastrillo/rastrillo" |
| ) |
| @@ -16,6 +17,13 @@ type homeLinkPage struct { |
| Title, Body, Address, Action, ActionLabel, CancelLabel string |
| PostAction bool |
| SignedOut *chrome.SignInNotice |
| + // Choice is the member choice page's two buttons (connect's |
| + // ChoiceFor): both POST Action with choice and the form token. |
| + Choice *homeChoice |
| +} |
| + |
| +type homeChoice struct { |
| + Action, Token, ConnectLabel, NewLabel string |
| } |
| func (rd *renderer) homeLink(w http.ResponseWriter, r *http.Request, state, address string, status int) { |
| @@ -42,6 +50,18 @@ func (rd *renderer) homeLinkBack(w http.ResponseWriter, r *http.Request, state, |
| // in going back through Home when it is configured. |
| notice := chrome.SignInNotice{Icon: brand.Path("docs"), App: "Docs", Sky: sky.For(r.Host)}.SignedOut("/signin") |
| page.SignedOut, page.Title = ¬ice, notice.Page() |
| + case "choose": |
| + // A roster member with no account here yet (Home spec |
| + // 2026-11-14-oficina-id-native.md §8): connect an existing |
| + // email account, or continue with Oficina ID as someone new. |
| + form, ok := connect.ChoiceFor(r) |
| + if !ok { |
| + state, status = "failed", http.StatusForbidden |
| + page.Action = "/account/home" |
| + page.ActionLabel = rastrillo.T(r, key+"menu_action") |
| + break |
| + } |
| + page.Choice = &homeChoice{Action: form.Action, Token: form.Token, ConnectLabel: rastrillo.T(r, key+"choose_connect_action"), NewLabel: rastrillo.T(r, key+"choose_new_action")} |
| case "success": |
| page.Action = "/" |
| if back != "" { |
diff --git a/internal/docs/identity.go b/internal/docs/identity.go| index 4afe094..956b245 100644 |
| --- a/internal/docs/identity.go |
| +++ b/internal/docs/identity.go |
| @@ -5,6 +5,7 @@ import ( |
| "database/sql" |
| "errors" |
| "net/http" |
| + "time" |
| "amadan.net/oficina/home/connect" |
| "amadan.net/oficina/home/connect/linkstore" |
| @@ -13,9 +14,11 @@ import ( |
| "github.com/carlosframework/docs/internal/docs/principalstore" |
| ) |
| -// homeAssertionMethod is the session method of a Home sign-in. It is |
| -// connect's, and was Docs' own string before Docs used connect, so sessions |
| -// minted then are still Home sessions now. |
| +// homeAssertionMethod is the session method of a browser Home sign-in. It |
| +// is connect's, and was Docs' own string before Docs used connect, so |
| +// sessions minted then are still Home sessions now. Checks on a Home |
| +// sign-in ask connect.IsHomeDerived, which also covers the native app's |
| +// (connect.NativeMethod) and native-to-web sessions. |
| const homeAssertionMethod = connect.HomeMethod |
| var ( |
| @@ -76,7 +79,14 @@ func (v identityResolver) resolve(r *http.Request) (requestIdentity, error) { |
| if v.store.team != nil && v.team == nil { |
| return requestIdentity{}, errIdentityRefused |
| } |
| - if session.Method == homeAssertionMethod { |
| + if connect.IsHomeDerived(session.Method) { |
| + // A browser, native or native-web sign-in through Home. The two |
| + // native kinds end seven days after they were minted, however |
| + // recently used (connect.Expired); Docs resolves sessions itself, |
| + // so it refuses what connect's ResolveSession would. |
| + if connect.Expired(connect.Session{Subject: session.Subject, Method: session.Method, AuthTime: session.AuthTime, At: session.At}, time.Now()) { |
| + return requestIdentity{}, errIdentityRefused |
| + } |
| person, err := v.homePerson(r.Context(), session.Subject) |
| if err != nil { |
| return requestIdentity{}, err |
diff --git a/internal/docs/render.go b/internal/docs/render.go| index 85ccdb5..5786c5d 100644 |
| --- a/internal/docs/render.go |
| +++ b/internal/docs/render.go |
| @@ -61,6 +61,12 @@ var Catalog = rastrillo.Catalog{ |
| "docs.home.success_body": "You can now use your Oficina account to sign in to this Docs account.", |
| "docs.home.documents_action": "Back to documents", |
| "docs.home.menu_action": "Connect your Oficina account", |
| + // The member choice (Home spec 2026-11-14-oficina-id-native.md §8): |
| + // a roster member arriving with no account here yet. |
| + "docs.home.choose_title": "Welcome to the team", |
| + "docs.home.choose_body": "Do you already have an account here that signs in with email? Connect it, and your Oficina ID will open it from now on. If you’re new here, continue with Oficina ID.", |
| + "docs.home.choose_connect_action": "Connect my existing account", |
| + "docs.home.choose_new_action": "I’m new here — continue with Oficina ID", |
| // docs.list.* — GET /, spec §6.4. Title is the screen's noun, per |
| // page-header's own contract ("Posts", not "Home"). The four group |
diff --git a/internal/docs/team_access.go b/internal/docs/team_access.go| index 81a12c7..55b37dc 100644 |
| --- a/internal/docs/team_access.go |
| +++ b/internal/docs/team_access.go |
| @@ -6,6 +6,7 @@ import ( |
| "net/http" |
| "strings" |
| + "amadan.net/oficina/home/connect" |
| "amadan.net/oficina/home/roster" |
| "amadan.net/oficina/home/teammode" |
| "amadan.net/rastrillo/rastrillo" |
| @@ -300,7 +301,7 @@ func requireTeamAccountAdmission(list allowlist) func(http.Handler) http.Handler |
| local := requireAdmission(list, "/signin/local")(next) |
| return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| id, ok := currentIdentity(r) |
| - if ok && id.Actor.VerifiedAddress == nil && id.Session.Method == homeAssertionMethod { |
| + if ok && id.Actor.VerifiedAddress == nil && connect.IsHomeDerived(id.Session.Method) { |
| next.ServeHTTP(w, r) |
| return |
| } |
diff --git a/internal/docs/team_home_test.go b/internal/docs/team_home_test.go| index 6ebac9d..85147dc 100644 |
| --- a/internal/docs/team_home_test.go |
| +++ b/internal/docs/team_home_test.go |
| @@ -113,6 +113,40 @@ func TestTeamUnlinkedAllocatesOnlyForAMemberThroughBothGates(t *testing.T) { |
| } |
| } |
| +// Admit is the roster decision connect takes first: a Member is nil, a |
| +// stranger or another issuer connect's ErrNoPerson, an undecidable roster |
| +// (or no runtime) unavailable, and it allocates nothing, ever. |
| +func TestTeamAdmitDecidesAndAllocatesNothing(t *testing.T) { |
| + f := newTeamHooksFixture(t) |
| + ctx, issuer := t.Context(), f.rt.bindings.Issuer |
| + if e := f.h.admit(ctx, issuer, f.member); e != nil { |
| + t.Fatal("a member was not admitted", e) |
| + } |
| + stranger := "pr_" + "bbbbbbbbbbbbbbbbbbbbbbbbbb" |
| + for name, e := range map[string]error{ |
| + "stranger": f.h.admit(ctx, issuer, stranger), |
| + "other issuer": f.h.admit(ctx, "https://other.example", f.member), |
| + "not a ref": f.h.admit(ctx, issuer, "someone@example.com"), |
| + } { |
| + if !errors.Is(e, connect.ErrNoPerson) { |
| + t.Errorf("%s: %v", name, e) |
| + } |
| + } |
| + if f.calls != 0 || f.allocated(t, f.member) || f.allocated(t, stranger) { |
| + t.Fatal("Admit allocated or asked the allocation gate", f.calls) |
| + } |
| + if people, docs := f.persons(); people != 1 || docs != 1 { |
| + t.Fatal("Admit fabricated a local person or samples", people, docs) |
| + } |
| + f.clock.step(61 * time.Second) |
| + if e := f.h.admit(ctx, issuer, "pr_"+"cccccccccccccccccccccccccc"); e == nil || errors.Is(e, connect.ErrNoPerson) { |
| + t.Fatal("an undecided roster was not retryable", e) |
| + } |
| + if e := (&homeRoutes{}).admit(ctx, issuer, f.member); e == nil || errors.Is(e, connect.ErrNoPerson) { |
| + t.Fatal("no team runtime was not unavailable", e) |
| + } |
| +} |
| + |
| // A subject linked to a local account in the meantime is that account, |
| // never a second, Home-only one. |
| func TestTeamUnlinkedRefusesALinkedSubject(t *testing.T) { |
| @@ -188,3 +222,18 @@ func homeOnlySubjects(rt *teamRuntime) subjectsFunc { |
| return p, nil |
| } |
| } |
| + |
| +// The member choice speaks the spec's words (Home spec |
| +// 2026-11-14-oficina-id-native.md §8), typeset as Docs' copy is. |
| +func TestChooseCopyIsTheSpecs(t *testing.T) { |
| + for key, want := range map[string]string{ |
| + "docs.home.choose_title": "Welcome to the team", |
| + "docs.home.choose_body": "Do you already have an account here that signs in with email? Connect it, and your Oficina ID will open it from now on. If you’re new here, continue with Oficina ID.", |
| + "docs.home.choose_connect_action": "Connect my existing account", |
| + "docs.home.choose_new_action": "I’m new here — continue with Oficina ID", |
| + } { |
| + if Catalog[key] != want { |
| + t.Errorf("%s = %q", key, Catalog[key]) |
| + } |
| + } |
| +} |
diff --git a/internal/docs/team_probe_test.go b/internal/docs/team_probe_test.go| index 6bc940f..182dc4a 100644 |
| --- a/internal/docs/team_probe_test.go |
| +++ b/internal/docs/team_probe_test.go |
| @@ -120,7 +120,7 @@ func TestTeamProbeCarriesNoAccountData(t *testing.T) { |
| // who is asking. |
| b := f.browser() |
| nonce := b.start(t, "/auth/start?return_to=%2F", "") |
| - routerRedirect(t, b.exchange(t, nonce, teamSubject('b'), time.Now()), "/") |
| + b.chooseNew(t, b.exchange(t, nonce, teamSubject('b'), time.Now())) |
| member := b.do("GET", teamProbePath, "") |
| probeBody(t, member) |
| if !bytes.Equal(member.Body.Bytes(), anonymous.Body.Bytes()) { |
diff --git a/internal/docs/team_router_test.go b/internal/docs/team_router_test.go| index 4157677..e27e904 100644 |
| --- a/internal/docs/team_router_test.go |
| +++ b/internal/docs/team_router_test.go |
| @@ -14,11 +14,13 @@ import ( |
| "net/http/httptest" |
| "net/url" |
| "path/filepath" |
| + "regexp" |
| "strings" |
| "sync" |
| "testing" |
| "time" |
| + "amadan.net/oficina/home/connect" |
| "amadan.net/oficina/home/roster" |
| family "amadan.net/rastrillo/rastrillo/crypto" |
| "amadan.net/rastrillo/rastrillo/sessions" |
| @@ -168,6 +170,30 @@ func newTeamRouterFixtureWithDashboard(t *testing.T, dashboard bool) *teamRouter |
| return f |
| } |
| func teamSubject(c byte) string { return "pr_" + strings.Repeat(string(c), 26) } |
| + |
| +var chooseToken = regexp.MustCompile(`name="token" value="([A-Za-z0-9_-]{43})"`) |
| + |
| +// chooseNew follows a roster member's first finish (Home spec |
| +// 2026-11-14-oficina-id-native.md §8): the choose page, then "I'm new here". |
| +// Nothing is allocated before the POST. |
| +func (b *routerBrowser) chooseNew(t *testing.T, finish *httptest.ResponseRecorder) { |
| + t.Helper() |
| + routerRedirect(t, finish, connect.ChoosePath) |
| + page := b.do("GET", connect.ChoosePath, "") |
| + body := page.Body.String() |
| + // Tests render catalog keys (NewForTest wires no BaseCatalog); the |
| + // copy itself is TestChooseCopyIsTheSpecs. |
| + for _, want := range []string{"docs.home.choose_title", "docs.home.choose_body", `name="choice" value="connect"`, `name="choice" value="new"`} { |
| + if page.Code != 200 || !strings.Contains(body, want) { |
| + t.Fatalf("choose page=%d lacks %s\n%s", page.Code, want, body) |
| + } |
| + } |
| + m := chooseToken.FindStringSubmatch(body) |
| + if m == nil { |
| + t.Fatal("choose page carries no form token") |
| + } |
| + routerRedirect(t, b.do("POST", connect.ChoosePath, url.Values{"choice": {"new"}, "token": {m[1]}}.Encode()), "/") |
| +} |
| func (b *routerBrowser) update(doc *Document, body []byte) int { |
| r := b.request("POST", "/d/"+doc.Sqid+"/updates", string(body)) |
| r.Header.Set("Content-Type", "application/octet-stream") |
| @@ -273,7 +299,7 @@ func TestTeamRouterHomeOnlyFirstEntryAndConflict(t *testing.T) { |
| f := newTeamRouterFixture(t) |
| b := f.browser() |
| nonce := b.start(t, "/auth/start?return_to=%2F", "") |
| - routerRedirect(t, b.exchange(t, nonce, teamSubject('b'), time.Now().Add(-time.Hour)), "/") |
| + b.chooseNew(t, b.exchange(t, nonce, teamSubject('b'), time.Now().Add(-time.Hour))) |
| p, e := f.app.store.team.principals.Resolve(t.Context(), bridgeIssuer, teamSubject('b')) |
| if e != nil || p.Kind != principalstore.Home || p.VerifiedAddress != nil { |
| t.Fatal("first Home entry did not create addressless principal", e) |
diff --git a/internal/docs/views/home_link.html b/internal/docs/views/home_link.html| index 886b80c..2e4bf38 100644 |
| --- a/internal/docs/views/home_link.html |
| +++ b/internal/docs/views/home_link.html |
| @@ -8,7 +8,11 @@ |
| {{- /* One row with the door's gap, primary first: rastrillo's form-foot, |
| as estilo's homeconnect lays out the same screens for the other apps. */}} |
| <div rst-form-foot> |
| - {{- if .PostAction}}<form method="post" action="{{.Action}}"><button rst-btn="primary" type="submit">{{.ActionLabel}}</button></form> |
| + {{- if .Choice}} |
| + {{- /* The member choice: two POSTs carrying the proof's form token. */}} |
| + <form method="post" action="{{.Choice.Action}}"><input type="hidden" name="token" value="{{.Choice.Token}}"><button rst-btn="primary" type="submit" name="choice" value="connect">{{.Choice.ConnectLabel}}</button></form> |
| + <form method="post" action="{{.Choice.Action}}"><input type="hidden" name="token" value="{{.Choice.Token}}"><button rst-btn="ghost" type="submit" name="choice" value="new">{{.Choice.NewLabel}}</button></form> |
| + {{- else if .PostAction}}<form method="post" action="{{.Action}}"><button rst-btn="primary" type="submit">{{.ActionLabel}}</button></form> |
| {{- else}}<a rst-btn="primary" href="{{.Action}}">{{.ActionLabel}}</a>{{end}} |
| {{- if .CancelLabel}}<a rst-btn="ghost" href="/">{{.CancelLabel}}</a>{{end}}</div> |
| </div> |