Accounts people can create, and photos on a server with no bucket

A tenant had exactly the users somebody had created with a command on the
server. That is not a missing screen: a shop with an owner and four staff
either shared one password or raised a ticket per person, and a phone app
for the shop floor could not exist while there was one account to sign in
as.

Registration is by invitation, never open signup - the same line already
drawn around creating a company. The code carries the address and the role
and the request carries only a password, so a code that gets forwarded
cannot become somebody else's account, and a staff invitation cannot be
redeemed as an owner. Single use lives in the UPDATE and the account is
created in the same transaction.

Deactivating a member revokes their sessions in that transaction too. An
access token lives twelve hours, so without it "remove their access"
removed it sometime tomorrow. The session list and revoke that go with it
are the benefit of opaque tokens the product had been paying for and never
collecting: nothing could say what was signed in, let alone stop one.

Face images now work on a deployment with no object storage, which was
every local install and every self-hosted site - the arrivals feed said
"not storing customer photos" for every customer forever, on the screen
whose whole job is to show a face. Bounded to one row per visitor, so it
grows with the customer base and not with footfall; the bucket stays
primary wherever one exists.

Image.auth says whether a URL needs the session, because a browser img
cannot load one that does, a mobile image view can, and a webview can do
neither - the desktop client resolves those to a data URI in Go.

Found by running it, not by tests:

  * UPDATE ... RETURNING gives the value AFTER the update, so the prune
    read back empty keys, deleted nothing, and the table grew with
    footfall exactly as if it were not there. The fake agreed with either
    version; only the live Postgres test caught it.
  * Trusting only the auth flag broke every shop card, because Sites.jsx
    rebuilt a partial snapshot object and dropped it. A relative URL is
    now sufficient on its own.
  * ago() renders a future time as "just now", so a code valid for a week
    read "expires just now".

Verified live against real Postgres: invite, preview, escalation refused,
register into a session, replay 404, staff forbidden, device revoked and
401 at once, last owner refused, and a 92,405-byte camera JPEG stored,
served to its owner, 401 with no session, 404 to another tenant, and
rendered in a browser.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HViLj9gYNRtSr7YVZmW5sn
This commit is contained in:
2026-09-05 11:45:42 +05:30
parent ffae7e45d5
commit 3f9fb33b24
38 changed files with 4125 additions and 106 deletions

View File

@@ -182,7 +182,12 @@ button.ghost:hover { border-color: var(--muted); color: var(--ink); }
.arrivals { list-style: none; padding: 0; display: grid; gap: 8px; }
.card.arrival { display: flex; align-items: center; gap: 14px; padding: 11px 14px; }
.face { width: 46px; height: 46px; border-radius: 50%; flex: none;
object-fit: cover; background: var(--surface-2); }
overflow: hidden; object-fit: cover; background: var(--surface-2); }
/* .face is a <span> wrapping the picture rather than the <img> itself, because
a face served from this server's own database has to be fetched with the
session before it can be shown. The image inside still has to fill the
circle, and the wrapper clips it. */
.face > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face.initials { display: grid; place-items: center; color: var(--muted);
font-size: 15px; font-weight: 600; letter-spacing: .02em; }
.who-col { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
@@ -536,3 +541,30 @@ button.ghost.danger:hover { border-color: var(--bad); }
font-size: 13px; color: rgba(255, 255, 255, .78);
background: rgba(0, 0, 0, .35);
}
/* ---------------------------------------------------------------- team --- */
.rows tr.inactive td { opacity: .55; }
.rows .role { text-transform: capitalize; }
.rows td.right { text-align: right; }
.pill.muted { margin-left: 8px; font-size: 11px; padding: 1px 7px; border-radius: 999px;
background: var(--surface-2); color: var(--muted); vertical-align: middle; }
.pending { margin-top: 26px; }
.pending h2 { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 10px; }
.invites { list-style: none; padding: 0; display: grid; gap: 8px; }
.card.invite { display: flex; align-items: center; justify-content: space-between;
gap: 14px; padding: 11px 14px; }
.card.invite .sub { display: block; }
/* The code is read aloud and typed in, so it is set wide and monospaced.
Grouped in sixes by the server for the same reason. */
.creds code.big { font-size: 16px; letter-spacing: .06em; }
/* A button that reads as a link. Used where the action is a change of screen
rather than a submission, so it must not look like the primary button next
to it. */
.linkish { background: none; border: 0; padding: 0; font: inherit;
color: var(--accent); cursor: pointer; text-decoration: underline;
text-underline-offset: 2px; }
.linkish:hover { opacity: .8; }
/* The code is read off a screen or a phone call, so it is set wide. */
.codefield { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .04em; text-transform: uppercase; }