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
+10 -1
View File
@@ -24,7 +24,7 @@ import (
// viewer is who a request comes from.
type viewer struct {
User *users.User // nil on the local edition
User *users.User // nil on the local edition
Member users.Membership
Session *users.Session // nil on the local edition
}
@@ -99,6 +99,15 @@ func (s *Server) sessions(next http.Handler) http.Handler {
next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), viewerKey, localOwner)))
return
}
if !publicPath(r.URL.Path) || r.URL.Path == "/signin" {
if done, err := s.hasOwner(); err != nil {
s.serverError(w, err)
return
} else if !done {
s.setupUnfinished(w, r)
return
}
}
v, err := s.lookupSession(r)
if err != nil && !errors.Is(err, users.ErrNoSession) {
s.serverError(w, err)