oficina / slides Public

Slides: Connect your Oficina account only when it isn't, and finishes itself

The account menu offers Connect only when no Oficina link is stored. A
sign-in through id with an unlinked identity now leads, after one local
sign-in, straight to the confirm step, creating the local account first
if this is its first sign-in; the card's buttons sit in one row and a
stored link shows Accounts connected. Pins estilo f14458a and home
connect ff16bf5. Reviewed by GPT-6-Astra via Codex (#23).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from fix/connect-item-when-linked into main.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev fbd1c21304cecac301e1b07cad4d38332e8b039f parent 0a098cb
7 files changed, +396 −21
  • go.mod +3 −3
  • go.sum +6 −6
  • internal/slides/app.go +1 −1
  • internal/slides/chrome.go +14 −7
  • internal/slides/home.go +30 −1
  • internal/slides/home_menu_test.go +339 −0
  • internal/slides/locales/en.toml +3 −3

CI passed — run details

landed from fix/connect-item-when-linked

diff --git a/go.mod b/go.mod
index 969daad..54b3f0c 100644
--- a/go.mod
+++ b/go.mod
@@ -5,9 +5,9 @@ go 1.25.0
toolchain go1.26.5
require (
- amadan.net/oficina/estilo.git v0.0.0-20261024225350-d53b8e9533a1
- amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c
- amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489
+ amadan.net/oficina/estilo.git v0.0.0-20261024233714-f14458a4683c
+ amadan.net/oficina/home/connect v0.0.0-20261024233715-ff16bf56bc4d
+ amadan.net/oficina/home/handoff v0.0.0-20261024233715-ff16bf56bc4d
amadan.net/rastrillo/rastrillo v0.27.1-0.20261006204347-fb806a287060
github.com/chromedp/cdproto v0.0.0-20250724212937-08a3db8b4327
github.com/chromedp/chromedp v0.14.2
diff --git a/go.sum b/go.sum
index e8281d7..4614bc5 100644
--- a/go.sum
+++ b/go.sum
@@ -1,9 +1,9 @@
-amadan.net/oficina/estilo.git v0.0.0-20261024225350-d53b8e9533a1 h1:Xaidrm9rzFyne6PujFYXiY7nGRy+/KzH7kGBM2+D5LQ=
-amadan.net/oficina/estilo.git v0.0.0-20261024225350-d53b8e9533a1/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw=
-amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c h1:3yxO2D8BxDLMGfFV2o6Sp9Z91yLnjDCIuRKHVWORa8A=
-amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c/go.mod h1:YroavXe43Wietec+po8mtSk4a9Bir2h31Q3iAf4MWxI=
-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/estilo.git v0.0.0-20261024233714-f14458a4683c h1:jPbFJwPi7lHe+UNe+Gbj0ivVsy+pLqMSq2EP2Xff/q0=
+amadan.net/oficina/estilo.git v0.0.0-20261024233714-f14458a4683c/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw=
+amadan.net/oficina/home/connect v0.0.0-20261024233715-ff16bf56bc4d h1:9sVZBph2xUuejZt73DYaoCfoyvrvZCnuPHcyMsg562E=
+amadan.net/oficina/home/connect v0.0.0-20261024233715-ff16bf56bc4d/go.mod h1:ix81eFV87yE9f2SXiRuxYCVM4lAgTRC5YoQMiH3+TDk=
+amadan.net/oficina/home/handoff v0.0.0-20261024233715-ff16bf56bc4d h1:8RTZkLQnyxvH2g0RMovhN/m2LN9D8qb+kBfqdBeqq+s=
+amadan.net/oficina/home/handoff v0.0.0-20261024233715-ff16bf56bc4d/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k=
amadan.net/rastrillo/rastrillo v0.27.1-0.20261006204347-fb806a287060 h1:K2PXcCKfm+AYrqgH1ea6cNsFs4sN7MKLvq+uBY11NZE=
amadan.net/rastrillo/rastrillo v0.27.1-0.20261006204347-fb806a287060/go.mod h1:WmC8TAIfqjAkSwmD+FCTqr7VuqAO5FaX03HlV49K608=
amadan.net/rastrillo/rastrillo/money v0.1.0 h1:MxU4oqNrW8abxRTkgZBv24OYNpFnvonajNqeLIzmmaM=
diff --git a/internal/slides/app.go b/internal/slides/app.go
index 6f08bc2..349aa82 100644
--- a/internal/slides/app.go
+++ b/internal/slides/app.go
@@ -102,7 +102,7 @@ func New(d *db.DB, cfg Config) (*http.ServeMux, *app, error) {
r.Post("/auth/verify", h.LocalGuard(authPlugin.Verify))
r.Post("/signout", h.Signout)
r.Get("/signed-out", h.SignedOut)
- r.Get(connect.LocalCompletePath, h.LocalComplete)
+ r.Get(connect.LocalCompletePath, a.homeLocalComplete)
r.Get(handoff.StartPath, a.home.Start)
r.Post(handoff.CallbackPath, a.home.Callback)
r.Get(handoff.FinishPath, a.home.Finish)
diff --git a/internal/slides/chrome.go b/internal/slides/chrome.go
index ed7d2d1..beb072e 100644
--- a/internal/slides/chrome.go
+++ b/internal/slides/chrome.go
@@ -227,19 +227,26 @@ func (a *app) account(r *http.Request, v viewerState, ret string) *chrome.Accoun
// Agents (agents.go): the tokens that let a program drive this
// person's decks. A page, so a link and no ellipsis.
acc.Items = []estilomenu.Item{{Href: "/agents", Label: rastrillo.T(r, "slides.account.agents")}}
- if a.offersHomeLink(v) {
+ if a.offersHomeLink(r, v) {
acc.Items = append(acc.Items, estilomenu.Item{Href: "/account/home", Label: rastrillo.T(r, "slides.home.menu_action")})
}
return acc
}
// offersHomeLink is whether the account menu offers to connect the
-// person's Oficina account: only when Home is configured, and never to
-// somebody who signed in through Home, whose account already is the
-// connection (spec §12.1 item 4; before this Slides offered it to Home
-// sessions too).
-func (a *app) offersHomeLink(v viewerState) bool {
- return a.home != nil && v.ok && v.method != connect.HomeMethod
+// person's Oficina account: only when Home is configured and this
+// person's account has no stored link yet. The stored link decides, not
+// how this session signed in: somebody already linked who signed in with
+// the emailed link is still linked, and used to be offered it anyway
+// (Paul hit this). One lookup on the links table's unique (issuer,
+// person_id) index, on each render that draws the menu; an error means
+// unknown, and offers nothing.
+func (a *app) offersHomeLink(r *http.Request, v viewerState) bool {
+ if a.home == nil || !v.ok || v.user.ID == 0 {
+ return false
+ }
+ linked, err := a.home.Linked(r.Context(), v.user.ID)
+ return err == nil && !linked
}
// switcher is the app switcher, or nil when no hub directory is
diff --git a/internal/slides/home.go b/internal/slides/home.go
index d995a05..b9221a8 100644
--- a/internal/slides/home.go
+++ b/internal/slides/home.go
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"net/http"
+ "time"
"amadan.net/oficina/home/connect"
"amadan.net/oficina/home/connect/linkstore"
@@ -103,7 +104,7 @@ func (a *app) renderHome(w http.ResponseWriter, r *http.Request, state, label st
a.renderSignedOut(w, r, status)
return
}
- page := connect.Page(state, label, func(key string) string { return rastrillo.T(r, "slides.home."+key) })
+ page := connect.PageFor(r, state, label, func(key string) string { return rastrillo.T(r, "slides.home."+key) })
var buf bytes.Buffer
if err := pages["home_link"].ExecuteTemplate(&buf, "layout", homeLinkView{shell: a.publicShell(r, titled(page.Title)), PageData: page}); err != nil {
a.logger.Error("slides: render Home account page", "err", err)
@@ -175,3 +176,31 @@ func restoreExportPrincipal(r *http.Request) *http.Request {
}
return r
}
+
+// homeLocalComplete is GET /auth/local/complete with Home configured: where
+// a local sign-in lands. After an Oficina assertion Slides had no link for,
+// connect resumes the link from here, and that needs the person's users
+// row. A first-ever local sign-in has none yet (currentUser creates it on
+// the first page), so the resume fell to /account/home, which answered 403
+// (Astra's review of #23). A fresh, admitted local session gets its row
+// here first, exactly as currentUser would make it, sample deck included;
+// any other request is passed on untouched. Failing costs only the
+// shortcut: the sign-in itself has already succeeded.
+func (a *app) homeLocalComplete(w http.ResponseWriter, r *http.Request) {
+ if s, ok := a.homeSessions.From(r); ok && (s.Method == "magiclink" || s.Method == "keymail") && a.allowed.allows(s.Subject) {
+ if _, fresh := connect.FreshLocal(neutralSession(s), time.Now()); fresh {
+ u, created, err := ensureUser(r.Context(), a.db.G, s.Subject)
+ switch {
+ case err != nil:
+ a.logger.Error("slides: create user before resuming a Home link", "err", err)
+ case created:
+ if has, err := hasDeck(r.Context(), a.db.G, u); err != nil {
+ a.logger.Error("slides: check for an existing deck before seeding", "user", u.ID, "err", err)
+ } else if !has {
+ a.seedSampleDeckFor(r.Context(), u)
+ }
+ }
+ }
+ }
+ a.homeRoutes.LocalComplete(w, r)
+}
diff --git a/internal/slides/home_menu_test.go b/internal/slides/home_menu_test.go
new file mode 100644
index 0000000..168e7af
--- /dev/null
+++ b/internal/slides/home_menu_test.go
@@ -0,0 +1,339 @@
+package slides
+
+import (
+ "html"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "regexp"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/home/connect"
+ "amadan.net/oficina/home/handoff"
+ "amadan.net/rastrillo/rastrillo"
+ "amadan.net/rastrillo/rastrillo/assertion"
+ assertioncrypto "amadan.net/rastrillo/rastrillo/crypto"
+)
+
+// The account menu's "Connect your Oficina account" follows the stored
+// link, not how this session signed in (Paul hit the item while already
+// linked, signed in with the emailed link). These run the app's real
+// router under the locale middleware, with one browser's cookie jar.
+
+const menuItem = `href="/account/home"`
+const menuLabel = "Connect your Oficina account"
+
+// homeBrowser is one browser against the Home-configured app.
+type homeBrowser struct {
+ t *testing.T
+ a *app
+ key *assertioncrypto.Keypair
+ h http.Handler
+ jar map[string]*http.Cookie
+}
+
+func newHomeBrowser(t *testing.T) (*homeBrowser, User) {
+ t.Helper()
+ mux, a, u, key := homeFixtureKey(t)
+ loc, err := rastrillo.NewLocales(Locales, DefaultLocale, rastrillo.BaseCatalog(), LocaleFS)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return &homeBrowser{t: t, a: a, key: key, h: loc.Middleware(mux), jar: map[string]*http.Cookie{}}, u
+}
+
+func (b *homeBrowser) set(c *http.Cookie) { b.jar[c.Name] = c }
+
+func (b *homeBrowser) do(method, path string, form url.Values, origin string) *httptest.ResponseRecorder {
+ b.t.Helper()
+ var body *strings.Reader
+ if form != nil {
+ body = strings.NewReader(form.Encode())
+ } else {
+ body = strings.NewReader("")
+ }
+ r := httptest.NewRequest(method, homeTestOrigin+path, body)
+ r.Header.Set("Accept", "text/html")
+ if method == http.MethodPost {
+ r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ if origin == "" {
+ origin = homeTestOrigin
+ }
+ }
+ if origin != "" {
+ r.Header.Set("Origin", origin)
+ }
+ for _, c := range b.jar {
+ r.AddCookie(c)
+ }
+ w := httptest.NewRecorder()
+ b.h.ServeHTTP(w, r)
+ for _, c := range w.Result().Cookies() {
+ if c.MaxAge < 0 {
+ delete(b.jar, c.Name)
+ } else {
+ b.jar[c.Name] = c
+ }
+ }
+ return w
+}
+
+func (b *homeBrowser) get(path string) *httptest.ResponseRecorder {
+ return b.do(http.MethodGet, path, nil, "")
+}
+
+// home answers the Home request at loc, as Oficina would, with a signed
+// assertion for subject, and follows the callback to the finish redirect.
+func (b *homeBrowser) home(loc, subject string) *httptest.ResponseRecorder {
+ b.t.Helper()
+ target, err := url.Parse(loc)
+ if err != nil || target.Query().Get("nonce") == "" {
+ b.t.Fatalf("not a Home request: %q", loc)
+ }
+ id, _ := assertion.RandomID()
+ now := time.Now().Unix()
+ token, err := assertion.Sign(b.key, assertion.Claims{Version: 1, Issuer: b.a.cfg.Home.Issuer, Audience: homeTestOrigin, Subject: subject, KeyID: "test", ID: id, Nonce: target.Query().Get("nonce"), IssuedAt: now, ExpiresAt: now + 90, AuthTime: now})
+ if err != nil {
+ b.t.Fatal(err)
+ }
+ cb := b.do(http.MethodPost, handoff.CallbackPath, url.Values{"assertion": {token}}, b.a.cfg.Home.Issuer)
+ if cb.Code != 303 {
+ b.t.Fatal("callback", cb.Code, cb.Body.String())
+ }
+ return b.get(handoff.FinishPath)
+}
+
+// localSignIn signs in with the emailed link through the real form, mail
+// and confirm door, and returns the verify POST's response.
+func (b *homeBrowser) localSignIn(address string) *httptest.ResponseRecorder {
+ b.t.Helper()
+ sent := b.do(http.MethodPost, "/signin", url.Values{"address": {address}}, "")
+ if sent.Code != 303 {
+ b.t.Fatal("send", sent.Code, sent.Body.String())
+ }
+ b.a.FlushMail()
+ link := regexp.MustCompile(`https://[^\s<>]+/auth/verify\?token=[A-Za-z0-9_-]+`).FindString(b.a.cfg.Mailer.(*homeTestMail).body)
+ if link == "" {
+ b.t.Fatal("no sign-in link mailed")
+ }
+ parsed, _ := url.Parse(link)
+ open := b.get(parsed.RequestURI())
+ m := confirmForm.FindStringSubmatch(open.Body.String())
+ if open.Code != 200 || m == nil {
+ b.t.Fatal("confirm door", open.Code, open.Body.String())
+ }
+ return b.do(http.MethodPost, html.UnescapeString(m[1]), url.Values{"token": {html.UnescapeString(m[2])}}, "")
+}
+
+func (b *homeBrowser) linkRows() int64 {
+ var n int64
+ if err := b.a.db.G.Table("home_identity_links").Count(&n).Error; err != nil {
+ b.t.Fatal(err)
+ }
+ return n
+}
+
+// menuOffers renders the deck list and reports whether its account menu
+// offers the connection.
+func (b *homeBrowser) menuOffers() bool {
+ b.t.Helper()
+ w := b.get("/")
+ if w.Code != 200 || !strings.Contains(w.Body.String(), "Sign out") {
+ b.t.Fatalf("deck list not rendered signed in: %d\n%s", w.Code, w.Body.String())
+ }
+ body := w.Body.String()
+ return strings.Contains(body, menuItem) && strings.Contains(body, menuLabel)
+}
+
+func TestHomeMenuOffersConnectToUnlinkedLocalSession(t *testing.T) {
+ b, u := newHomeBrowser(t)
+ b.set(homeSession(t, b.a, u.Email, "magiclink"))
+ if !b.menuOffers() {
+ t.Fatal("an unlinked local session is not offered Connect your Oficina account")
+ }
+}
+
+// The bug: linked, but signed in with the emailed link.
+func TestHomeMenuHidesConnectFromLinkedLocalSession(t *testing.T) {
+ b, u := newHomeBrowser(t)
+ homeLinked(t, b.a, u)
+ b.set(homeSession(t, b.a, u.Email, "magiclink"))
+ if b.menuOffers() {
+ t.Fatal("a linked person signed in locally is still offered Connect your Oficina account")
+ }
+}
+
+func TestHomeMenuHidesConnectFromHomeSession(t *testing.T) {
+ b, u := newHomeBrowser(t)
+ homeLinked(t, b.a, u)
+ b.set(homeSession(t, b.a, "home-person", connect.HomeMethod))
+ if b.menuOffers() {
+ t.Fatal("a Home session is offered Connect your Oficina account")
+ }
+}
+
+// Right after the confirm POST, in the same session: Accounts connected,
+// the row stored, and the menu item gone on the next page.
+func TestHomeMenuConnectThenAccountsConnectedAndItemGone(t *testing.T) {
+ b, u := newHomeBrowser(t)
+ b.set(homeSession(t, b.a, u.Email, "magiclink"))
+ if !b.menuOffers() {
+ t.Fatal("precondition: the item is offered before linking")
+ }
+ start := b.do(http.MethodPost, "/account/home", nil, "")
+ if start.Code != 303 {
+ t.Fatal("start", start.Code, start.Body.String())
+ }
+ auth := b.get(start.Header().Get("Location"))
+ finish := b.home(auth.Header().Get("Location"), "menu-home-person")
+ if finish.Code != 303 || finish.Header().Get("Location") != "/account/home/confirm" {
+ t.Fatal("finish", finish.Code, finish.Header())
+ }
+ page := b.get("/account/home/confirm")
+ if page.Code != 200 || !strings.Contains(page.Body.String(), "Connect these two accounts?") || !strings.Contains(page.Body.String(), "Connect it to the Slides account below") {
+ t.Fatalf("confirm page lacks its own title and copy: %d\n%s", page.Code, page.Body.String())
+ }
+ post := b.do(http.MethodPost, "/account/home/confirm", nil, "")
+ loc := post.Header().Get("Location")
+ if post.Code != 303 || !strings.HasPrefix(loc, "/account/home/confirm?") || !strings.Contains(loc, "connected=1") {
+ t.Fatalf("confirm POST does not lead to Accounts connected: %d %q", post.Code, loc)
+ }
+ if n := b.linkRows(); n != 1 {
+ t.Fatalf("link rows after confirm = %d, want 1", n)
+ }
+ if person, err := b.a.home.Resolve(t.Context(), "menu-home-person"); err != nil || person.ID != u.ID {
+ t.Fatal("stored link does not resolve to the local person", person, err)
+ }
+ done := b.get(loc)
+ if done.Code != 200 || !strings.Contains(done.Body.String(), "Accounts connected") {
+ t.Fatalf("Accounts connected not shown: %d\n%s", done.Code, done.Body.String())
+ }
+ if !strings.Contains(done.Body.String(), `<a rst-btn="primary" href="/">Back to Slides</a>`) {
+ t.Fatal("Accounts connected has no way back\n" + done.Body.String())
+ }
+ // Its way back is the page the link began from (connect.PageFor),
+ // not always the deck list.
+ back := b.get("/account/home/confirm?connected=1&return_to=%2Fagents")
+ if back.Code != 200 || !strings.Contains(back.Body.String(), `<a rst-btn="primary" href="/agents">Back to Slides</a>`) {
+ t.Fatalf("Accounts connected does not lead back to where the link began: %d\n%s", back.Code, back.Body.String())
+ }
+ if b.menuOffers() {
+ t.Fatal("the menu still offers Connect your Oficina account after the link was stored")
+ }
+}
+
+// An ordinary Home sign-in with an unlinked subject shows the unknown
+// page; a local sign-in in the same browser then resumes the link,
+// through a fresh Home assertion and the explicit confirm.
+func TestHomeUnknownAssertionResumesLinkAfterLocalSignIn(t *testing.T) {
+ b, u := newHomeBrowser(t)
+ b.unknownThenResume(t, u.Email, u.ID)
+}
+
+// TestHomeUnknownAssertionResumesForAFirstLocalSignIn is the same flow for
+// an admitted address with no users row yet (Astra's review of #23): the
+// first local sign-in must create the row before connect resumes, or the
+// resume falls to /account/home and that page answers 403.
+func TestHomeUnknownAssertionResumesForAFirstLocalSignIn(t *testing.T) {
+ b, u := newHomeBrowser(t)
+ if err := b.a.db.G.Delete(&User{}, u.ID).Error; err != nil {
+ t.Fatal(err)
+ }
+ b.unknownThenResume(t, u.Email, 0)
+ var created User
+ if err := b.a.db.G.Where("email = ?", u.Email).Take(&created).Error; err != nil || created.ID == u.ID {
+ t.Fatal("first local sign-in did not create its own users row", created, err)
+ }
+}
+
+// unknownThenResume runs an unknown Oficina arrival, a local sign-in as
+// email, the resumed fresh exchange and the explicit confirm, and checks
+// the link is stored only after the confirm, against the person signed in
+// (id, or any row with that address when id is 0).
+func (b *homeBrowser) unknownThenResume(t *testing.T, email string, id int64) {
+ t.Helper()
+ front := b.get("/signin")
+ if front.Code != 303 {
+ t.Fatal("front door", front.Code, front.Header())
+ }
+ auth := b.get(front.Header().Get("Location"))
+ unknown := b.home(auth.Header().Get("Location"), "unlinked-home-person")
+ body := unknown.Body.String()
+ if unknown.Code != 403 || !strings.Contains(body, "Oficina account not connected") || !strings.Contains(body, "Sign in to your Slides account once to connect it to your Oficina account.") {
+ t.Fatalf("not the unknown page: %d\n%s", unknown.Code, body)
+ }
+ if !regexp.MustCompile(`<a rst-btn="primary" href="/signin/local">`).MatchString(body) {
+ t.Fatal("the unknown page's button does not go to /signin/local\n" + body)
+ }
+ if b.get("/signin/local").Code != 200 {
+ t.Fatal("local sign-in form")
+ }
+ verify := b.localSignIn(email)
+ if verify.Code != 303 || verify.Header().Get("Location") != connect.LocalCompletePath {
+ t.Fatal("local verify", verify.Code, verify.Header())
+ }
+ resume := b.get(connect.LocalCompletePath)
+ if resume.Code != 303 || resume.Header().Get("Location") != "/auth/start?return_to=%2Faccount%2Fhome%2Fconfirm" {
+ t.Fatalf("local sign-in did not resume the link: %d %q", resume.Code, resume.Header().Get("Location"))
+ }
+ if b.jar["__Host-oficina-home-init"] == nil {
+ t.Fatal("resume set no link-init cookie")
+ }
+ fresh := b.get(resume.Header().Get("Location"))
+ target, _ := url.Parse(fresh.Header().Get("Location"))
+ if fresh.Code != 303 || target == nil || target.Query().Get("max_age") != "300" {
+ t.Fatal("resumed link did not ask Oficina for fresh authentication", fresh.Code, fresh.Header())
+ }
+ finish := b.home(fresh.Header().Get("Location"), "unlinked-home-person")
+ if finish.Code != 303 || finish.Header().Get("Location") != "/account/home/confirm" {
+ t.Fatal("finish", finish.Code, finish.Header())
+ }
+ if n := b.linkRows(); n != 0 {
+ t.Fatal("linked before the explicit confirm")
+ }
+ if page := b.get("/account/home/confirm"); page.Code != 200 || !strings.Contains(page.Body.String(), "Connect these two accounts?") {
+ t.Fatalf("confirm page: %d\n%s", page.Code, page.Body.String())
+ }
+ post := b.do(http.MethodPost, "/account/home/confirm", nil, "")
+ if post.Code != 303 || !strings.Contains(post.Header().Get("Location"), "connected=1") {
+ t.Fatal("confirm", post.Code, post.Header())
+ }
+ if person, err := b.a.home.Resolve(t.Context(), "unlinked-home-person"); err != nil || person.Label != email || (id != 0 && person.ID != id) {
+ t.Fatal("resumed link not stored", person, err)
+ }
+ if b.linkRows() != 1 {
+ t.Fatal("expected one link row")
+ }
+}
+
+// Without the remembered arrival, a local sign-in lands as before.
+func TestHomeLocalSignInWithoutMarkerLandsAsBefore(t *testing.T) {
+ b, u := newHomeBrowser(t)
+ verify := b.localSignIn(u.Email)
+ if verify.Code != 303 || verify.Header().Get("Location") != connect.LocalCompletePath {
+ t.Fatal("local verify", verify.Code, verify.Header())
+ }
+ if done := b.get(connect.LocalCompletePath); done.Code != 303 || done.Header().Get("Location") != "/" {
+ t.Fatalf("plain local sign-in did not land on /: %d %q", done.Code, done.Header().Get("Location"))
+ }
+ if b.jar["__Host-oficina-home-init"] != nil {
+ t.Fatal("a plain local sign-in began a link")
+ }
+}
+
+// The connect page's two buttons share one rst-form-foot row, primary
+// first (estilo's homeconnect template).
+func TestHomeConnectPageButtonsInOneFootRow(t *testing.T) {
+ b, u := newHomeBrowser(t)
+ b.set(homeSession(t, b.a, u.Email, "magiclink"))
+ w := b.get("/account/home")
+ if w.Code != 200 {
+ t.Fatal(w.Code)
+ }
+ row := regexp.MustCompile(`(?s)<div rst-form-foot>\s*<form method="post" action="/account/home"><button rst-btn="primary" type="submit">Connect</button></form>\s*<a rst-btn="ghost" href="/">Back</a>\s*</div>`)
+ if !row.MatchString(w.Body.String()) {
+ t.Fatalf("the Connect and Back buttons are not one rst-form-foot row, primary first:\n%s", w.Body.String())
+ }
+}
diff --git a/internal/slides/locales/en.toml b/internal/slides/locales/en.toml
index 4c48c12..30ede6c 100644
--- a/internal/slides/locales/en.toml
+++ b/internal/slides/locales/en.toml
@@ -602,11 +602,11 @@ slides.home.start_title = "Connect your Oficina account"
slides.home.start_body = "Use your Oficina account to sign in to this Slides account. Your decks and sharing settings stay as they are."
slides.home.start_action = "Connect"
slides.home.cancel_action = "Back"
-slides.home.confirm_title = "Confirm account connection"
-slides.home.confirm_body = "Connect the account below to the Oficina account you just signed in to."
+slides.home.confirm_title = "Connect these two accounts?"
+slides.home.confirm_body = "Your Oficina account is confirmed. Connect it to the Slides account below, and you can sign in to Slides with Oficina from now on."
slides.home.confirm_action = "Connect accounts"
slides.home.unknown_title = "Oficina account not connected"
-slides.home.unknown_body = "Sign in to your existing Slides account, then connect your Oficina account from the account menu."
+slides.home.unknown_body = "Sign in to your Slides account once to connect it to your Oficina account."
slides.home.local_action = "Sign in to your existing Slides account"
slides.home.failed_title = "Could not connect accounts"
slides.home.failed_body = "Return to Slides and start again."