Phase 10, part 2: the first owner, from a one-time setup link

A new server prints a link to create its owner (supermarket setup-link
makes another); until it's used, every page says the setup isn't
finished. One-time links (schema 33) are kept as hashes and used up in
one statement; resets and invitations will use them too. The server
edition opens Postgres.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 08:53:14 -07:00
co-authored by Claude Opus 5.5
parent 96404a3580
commit 72455438c9
16 changed files with 553 additions and 10 deletions
+15 -5
View File
@@ -20,6 +20,7 @@ import (
"supermarket/internal/jobs"
"supermarket/internal/storage"
"sync"
"sync/atomic"
"time"
"unicode"
"unicode/utf8"
@@ -67,8 +68,9 @@ type Server struct {
pages map[string]*template.Template
mu sync.Mutex
jobsOnce sync.Once
mu sync.Mutex
jobsOnce sync.Once
setupDone atomic.Bool // the team has its owner (server edition)
// Reddit: an app-only token for reading rules before sign-in, and the
// account's recent posts for the warnings.
@@ -135,6 +137,10 @@ func (s *Server) Handler() (http.Handler, error) {
mux.HandleFunc("GET /{$}", s.dashboard)
// Signing in (the server edition).
mux.HandleFunc("GET /setup/{token}", s.setupPage)
mux.HandleFunc("POST /setup/{token}", s.setupSave)
mux.HandleFunc("GET /search", s.searchPage)
mux.HandleFunc("GET /market", s.inventoryList)
@@ -511,6 +517,7 @@ type page struct {
NewProspects int // companies and people waiting for review, shown in the menu
Drafts int // outreach drafts waiting, shown in the menu
Bare bool // no sidebar: pages before signing in
CSRF string // the form token, for htmx (app.js)
Viewer *viewer // who's looking
}
@@ -560,9 +567,11 @@ func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, p p
return
}
p.Version = s.Version
p.Inbox = s.inboxCount()
p.NewProspects = s.newProspects()
p.Drafts = s.outreachDrafts()
if !p.Bare {
p.Inbox = s.inboxCount()
p.NewProspects = s.newProspects()
p.Drafts = s.outreachDrafts()
}
if p.Flash == "" {
p.Flash = flashText(r.URL.Query())
}
@@ -599,6 +608,7 @@ func (s *Server) fragment(w http.ResponseWriter, r *http.Request, page, name str
// Messages shown after a redirect, by code, so no user text is reflected.
var flashes = map[string]string{
"saved": "Saved.",
"welcome": "Welcome: you're the owner. Start with the company's profile.",
"deleted": "Deleted.",
"x-connected": "X is connected.",
"li-connected": "LinkedIn is connected.",