Submitter accounts
With accounts on, submitting means being signed in: an email and a password, or Google.
/dashboard/ is the submitter’s own area — their submissions and what they can do about
each, the listings they bookmarked, and their account. features.accounts: true in
site.config.ts turns it on.
The account icon in the header opens the sign-in card in a dialog, on the page the visitor
is already on. Its last line, “Don’t have an account? Sign up”, leads to /signup/, and
“Forgot password?” to a reset link by email. A signed-in visitor sees their avatar there
instead, with a menu: Dashboard, Bookmarks, Log out.
-
Switch accounts on.
site.config.ts features: { submissions: true, accounts: true },Terminal pnpm check:configsite.config.ts OK — <your site name> (https://your-domain.com). -
Apply the migrations.
Terminal pnpm devLocally this prints
dev: applied …. In production:pnpm db:migrate:remote, orpnpm cf:setup. -
Deploy, then open
/submit/signed out.Terminal pnpm deployYou land on
/login/?next=%2Fsubmit%2F. On any other page, press the account icon: the same card opens in a dialog and the address bar does not change. The one mail accounts send, the password-reset link, goes throughproviders.email— Email. -
Google, optionally: create the OAuth client.
Google Cloud console → APIs & Services → OAuth consent screen, scopes
openid,email,profile(in Testing, only its listed testers can sign in), then Credentials → Create credentials → OAuth client ID → Web application, authorised redirect URI:https://<your domain>/auth/google/callback/Keep the trailing slash. Copy the client id (
….apps.googleusercontent.com) and the secret (GOCSPX-…). To try it underpnpm dev, addhttp://localhost:4321/auth/google/callback/as a second redirect URI and put the same two keys in.env. -
Put both on the Worker.
Terminal pnpm cf:secrets GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRETBoth come from
.env.prod; a swapped pair is refused: “this is the client id — it belongs in GOOGLE_CLIENT_ID; the secret begins with GOCSPX-”.
Verify
Section titled “Verify”| What to check | Where | You should see |
|---|---|---|
| The gate | /dashboard/ or /submit/, signed out |
a 302 to /login/?next=…; /account/ is a 301 to /dashboard/ |
| The dialog | the account icon on any page, signed out | the sign-in card over the page; the address bar does not change; a wrong password comes back into it |
| Its card | curl -s https://<your domain>/login/dialog/ |
the card alone, no <html>; 204 when the request carries a session cookie |
| The sign-in page | /login/ |
200, Cache-Control: no-store, email and password fields; “Continue with Google” once both secrets are set |
| Sign up | /signup/ with a name, an address and a password |
you land on /dashboard/ (“Welcome, Ada” for an Ada Lovelace); the header shows an avatar whose menu names you |
| A wrong password | /login/ |
“Wrong email or password.” and nothing more; ten of them in a quarter of an hour lock the address for the rest of it |
| A reset link | /login/forgot/, then email_outbox |
a password-reset row with url /auth/reset/?token=…; the form there saves a new password and lands on /dashboard/ |
| Single use | open the same link again | 410 and “This link no longer works” |
/auth/google/ |
a 303 to Google, then back via /auth/google/callback/ to /dashboard/ |
|
| A submission | /submit/, signed in |
“Submitting as” your address; the row’s user_id is set; /dashboard/ counts it and /dashboard/submissions/ offers Upgrade and Withdraw on it |
| A withdrawal | Withdraw on /dashboard/submissions/, then Keep it / Withdraw |
the row reads “Withdrawn” under “Not listed”; /admin/ shows it as rejected with the reason Withdrawn by the submitter. |
| A bookmark | Bookmark on any listing page, signed in | it reads “Bookmarked” without leaving the page; /dashboard/bookmarks/ lists the listing; signed out, the same press opens the dialog |
| Sign out | Log out in the account menu, or on /dashboard/account/ |
you land on the home page, signed out; /dashboard/ gates again |



Worth knowing
Section titled “Worth knowing”- Passwords are at least eight characters and are stored hashed (PBKDF2-HMAC-SHA-256,
100,000 iterations, a salt per password). A sign-in, a sign-up and a reset each cost one
hash — about 15 ms of CPU on the Worker, more than the free plan’s nominal 10 ms per
request. If sign-ins on the free plan end in Cloudflare’s error 1102, lower
PASSWORD_ITERATIONSinsrc/server/auth/password.ts: stored passwords keep working and are re-hashed on the next sign-in. - Nothing checks the mailbox at sign-up. An address is proven by a Google sign-in or a completed reset, and the first time it is proven, a password somebody else had registered for it is dropped along with its sessions: the mailbox’s owner gets the account, and sets a password of their own with “Forgot password?”.
- A reset link works once, for twenty minutes; its mail is flushed as queued, not at the next hourly tick. Five links an hour per address.
- One
usersrow per address: a password and Google reach the same account. An account that has only used Google sets a first password on/dashboard/account/without being asked for a current one. - The dialog’s card is not in the static pages. It is fetched from
/login/dialog/when the dialog opens, because only the Worker knows whether the visitor has a session and whether the Google secrets are set — so adding them shows the button without a rebuild. - Content pages are static and the same for everyone, so the header learns who is signed in
from a second cookie,
zd_user— a name, an address and an avatar URL, readable by the page’s script and nothing a thief could use. The session is the HttpOnlyzd_session, and the server believes only that one. - The account icon is an ordinary link to
/dashboard/. With JavaScript off, on a new-tab click, or when the request fails, the visitor gets the/login/page as before. The dialog costs one inline script of about 2.6 KB on every page, and the Bookmark button one of about 0.8 KB on listing pages; no island, no<script src>. - A withdrawal is stored as a rejection with the reason
Withdrawn by the submitter., so the review queue and the operator’s listing page need nothing new to show it. Only a submission that is still waiting and not paid for can be withdrawn; a paid one is the operator’s to refund. A withdrawn or refused submission can no longer be paid for, and its address can be submitted again. - Bookmarks are keyed by the listing’s row id, which the demo seed keeps stable, so
pnpm content:usedoes not lose them; a bookmark whose listing is gone, or no longer published, is simply not shown. - The admins are accounts too:
admin.emailsnames them, and/admin/opens for a listed address once it is proven — Admin. login,signup,dashboard,accountandauthcannot be aroutes.*Base;robots.txtdisallows those paths.- Switching accounts off keeps the data: migrations only add.
When it is off or degraded
Section titled “When it is off or degraded”| Configuration | What a visitor sees | What /admin/ reports |
Fix |
|---|---|---|---|
features.accounts: false |
no account icon, no dialog, no Bookmark button; /login/, /signup/, /dashboard/ and /auth/reset/ answer 404; /auth/google/ → /login/ |
nothing | set it to true |
| one or both Google secrets missing | no “Continue with Google” button, in the dialog or on either page; /auth/google/ answers a 303 to /login/ |
nothing | pnpm cf:secrets GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRET |
| JavaScript off, or the dialog’s request fails | the account icon leads to /dashboard/, which redirects to /login/; the Bookmark button posts and lands on /dashboard/bookmarks/ |
nothing | nothing to fix |
providers.email: 'console' |
no reset link arrives; read url from the password-reset row in email_outbox |
warning: providers.email is "console": submitters get no mail, it is only logged. |
|
| the Google address is not verified, or the round trip failed | “Sign-in did not complete”; the Worker log says why (auth: Google sign-in did not complete — …) |
nothing | fix what the log names; the password still works |
| more than five reset links an hour for one address | “Check your inbox”, and nothing is sent | nothing | wait an hour |
| sign-ins end in error 1102 on the free plan | the sign-in request is cut off | nothing | lower PASSWORD_ITERATIONS (above) |
| the migrations are not applied | the pages fail with a no such table or no such column error |
nothing | pnpm db:migrate:local, or pnpm db:migrate:remote |
Configuration
Section titled “Configuration”features.accounts, providers.email, site.url — defaults in the reference: features, providers, site. The two Google keys are runtime secrets — Environment and secrets.
- site.config.ts
features.accounts - .env.example the two Google keys and where each comes from
Directorydrizzle/
- 0001_accounts.sql
users,sessions,login_tokens,listings.user_id - 0002_passwords.sql
users.password_hash,users.email_verified_at - 0003_bookmarks.sql
bookmarks
- 0001_accounts.sql
Directorysrc/
- db/schema.ts the four tables
- middleware.ts reads the session, gates
/dashboard/, keeps thezd_userhint in step Directoryserver/
- auth/index.ts sessions, passwords, reset links, the Google exchange,
sweepAuth - auth/password.ts the hash
- auth/cookies.ts
Set-Cookiestrings intoAstro.cookies - dashboard.ts what the dashboard reads, withdrawing, the table’s search and order
- bookmarks.ts the three queries and the endpoint
- auth/index.ts sessions, passwords, reset links, the Google exchange,
Directoryactions/
- auth.ts sign in, sign up, reset, the account page’s two forms, sign out
- dashboard.ts withdraw
Directorycomponents/
- account/AuthCard.astro the sign-in / sign-up / reset card: the form to edit
- account/AccountMenu.astro the signed-in visitor’s menu
- account/SubmissionList.astro the rows of the submissions page, with the two popovers
- site/LoginDialog.astro the empty dialog and its inline script
- listing/BookmarkButton.astro the button and its inline script
- layouts/Dashboard.astro the sidebar and the top bar
Directorypages/
- login/index.astro
- login/dialog.astro the card as a fragment, for the dialog
- login/forgot.astro
- signup/index.astro
- auth/reset.astro where the reset link lands
- auth/google/index.astro to Google
- auth/google/callback.astro back from Google
Directorydashboard/ index, submissions, bookmarks, account
- …
- api/bookmarks/[id].ts GET the state, POST save or remove
- account/index.astro the redirect to
/dashboard/
Directorytemplates/account/ AuthPage, DashboardOverview, DashboardSubmissions, DashboardBookmarks, DashboardAccount, LinkExpiredPage
- …
- server/email/templates/password-reset.ts the mail
- tests/e2e/accounts.spec.ts the gate, an account, a reset, the dashboard, the dialog, a bookmark, in a browser