Social accounts: X's 127.0.0.1 callback, "Get it" links, save in place; cart logo

- X refuses "localhost" in callback URLs, so its sign-in now uses
  http://127.0.0.1:8470/auth/x/callback (shown on the page and sent to X);
  LinkedIn and Reddit keep localhost.
- Every key, on Social accounts and the AI tab, has a "Get it" link to the
  service's page for it (opens a new tab) and says where on that page to
  find it. Addresses checked on 2026-11-21.
- Each network's card saves its own keys in place (htmx swaps the card),
  saying "Saved." and enabling Connect when ready; no reload. Without
  JavaScript it still saves and reloads.
- The shopping-cart image is the logo in the sidebar, the tab icon (PNG,
  and a multi-size favicon.ico at /favicon.ico) and the touch icon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 11:01:01 -07:00
co-authored by Claude Opus 5.5
parent d9b1467365
commit 1f181ed554
10 changed files with 154 additions and 47 deletions
+36 -1
View File
@@ -91,7 +91,7 @@ func TestEveryPageRenders(t *testing.T) {
for _, path := range []string{"/", "/?msg=saved", "/settings/profile", "/inventory", "/inventory?relationship=partner",
"/inventory/new", "/inventory/1", "/inventory/import", "/inventory/export",
"/settings/ai", "/settings/accounts", "/settings/core", "/static/app.css", "/search", "/search?q=rival", "/search?q=nothing+here", "/static/htmx.min.js", "/healthz",
"/settings/ai", "/settings/accounts", "/settings/core", "/static/app.css", "/favicon.ico", "/static/favicon.png", "/static/logo.png", "/search", "/search?q=rival", "/search?q=nothing+here", "/static/htmx.min.js", "/healthz",
"/content", "/content/1", "/content/1?dismissed=1", "/inbox", "/inbox?msg=drafted",
"/content/scheduled", "/content/published"} {
rec := do(h, http.MethodGet, path, nil, nil)
@@ -215,6 +215,18 @@ func TestAccountsKeepAndRemove(t *testing.T) {
if s.Secrets.Has(secrets.AnthropicAPIKey) {
t.Error("the accounts form saved an AI key")
}
// From the page, a save sends back just that card, updated, not a redirect.
rec := do(h, http.MethodPost, "/settings/accounts", strings.NewReader(url.Values{
"network": {"LinkedIn"}, secrets.LinkedInClientID: {"li"}, secrets.LinkedInClientSecret: {"ls"}}.Encode()),
map[string]string{"Content-Type": "application/x-www-form-urlencoded", "Origin": "http://localhost:8470", "HX-Request": "true"})
card := rec.Body.String()
if rec.Code != http.StatusOK || !strings.Contains(card, `id="network-LinkedIn"`) || strings.Contains(card, "<html") ||
!strings.Contains(card, "Saved.") || strings.Contains(card, "Save the client ID") || strings.Contains(card, `"li"`) {
t.Errorf("htmx save: %d\n%s", rec.Code, card)
}
if s.Secrets.Get(secrets.XClientID) != "id-1" {
t.Error("saving one card cleared another's keys")
}
page := do(h, http.MethodGet, "/settings/accounts", nil, nil).Body.String()
if strings.Contains(page, "id-1") {
t.Error("the accounts page must never show a saved value")
@@ -284,6 +296,29 @@ func TestSearch(t *testing.T) {
}
}
func TestCallbackURLs(t *testing.T) {
s, h := newTestServer(t, nil)
s.PublicURL = "http://localhost:8470"
for provider, want := range map[string]string{
"x": "http://127.0.0.1:8470/auth/x/callback", // X refuses localhost
"linkedin": "http://localhost:8470/auth/linkedin/callback",
"reddit": "http://localhost:8470/auth/reddit/callback",
} {
if got := s.callbackURL(provider); got != want {
t.Errorf("%s: %s", provider, got)
}
}
if body := do(h, http.MethodGet, "/settings/accounts", nil, nil).Body.String(); !strings.Contains(body, "http://127.0.0.1:8470/auth/x/callback") {
t.Error("the accounts page should show X's 127.0.0.1 callback")
}
// The sign-in sends the same address X has registered.
_ = s.Secrets.Set(map[string]string{secrets.XClientID: "cid"})
rec := postForm(h, "/auth/x/start", nil)
if loc := rec.Header().Get("Location"); !strings.Contains(loc, url.QueryEscape("http://127.0.0.1:8470/auth/x/callback")) {
t.Errorf("x start: %d %s", rec.Code, loc)
}
}
func TestOAuthCallbackRejectsUnknownState(t *testing.T) {
_, h := newTestServer(t, nil)
rec := do(h, http.MethodGet, "/auth/x/callback?state=nope&code=c", nil, nil)