ADR-WEB-6. Age gate, under-13 block and private defaults
Source:
docs/decisions/ADR-WEB-6-age-gate.md. Generated at build time; edit the source file.
Date: 2026-11-21. Status: accepted. Implements M4 Task 20. Builds on ADR-WEB-3 (auth data model) and spec §14 (age gate, cookies). The screens themselves (/welcome/age, /blocked) are Task 21.
Context
Section titled “Context”chess-improver is not for children under 13, and teenagers get the most private settings. The first target is an invite-only private beta (ADR 0041), but the gate has to be right from the first account, because it decides what personal data we hold about a child.
Decision
Section titled “Decision”A neutral screen after sign-in
Section titled “A neutral screen after sign-in”- The age question comes after authentication, on its own screen (“When were you born?”, month and year).
requireUsersends every account without abirthMonththere, andrequireApiUseranswers 403age_requireduntil it is answered. So no feature can be used first. - The screen does not announce the threshold in advance. The hint only says why we ask (“so we can keep younger players’ accounts private by default”). A child who is told “you must be 13” is invited to lie, and a neutral question gets more honest answers.
- The answer is given once.
POST /api/ageanswers 409age_already_recordedonce an age is stored, andrecordAgechecks again under a row lock. The gate can neither change a recorded age (a teen cannot become an adult) nor be replayed to delete someone else’s account.
Month and year only
Section titled “Month and year only”- We store
birth_monthasYYYY-MM(CHECK on the format, ADR-WEB-3) and the time of the answer,age_checked_at. Never a day of birth, and nothing at all for an under-13. This is data minimisation: the month and year are enough for every decision the product makes. parseBirthMonthaccepts integers only, months 1–12, years from 1900, and nothing after the current month.
Conservative arithmetic
Section titled “Conservative arithmetic”ageFromBirthMonthassumes the birthday is the last day of the birth month, so the age is never overstated. Someone born in November 2013 is 12 until 30 November 2026. A February birthday in a leap year counts from the 29th, which in other years means 1 March. All dates are UTC.- Bands: under 13
under13, 13–17teen, 18 and overadult. - An account with no recorded age counts as a minor (
isMinoris true), socanEnableMarketingis false until an adult age is recorded.
Privacy defaults
Section titled “Privacy defaults”marketing_emailandpublic_share_defaultdefault to false for everyone: both are opt-in.- A teen’s answer forces both to false, whatever they were.
canEnableMarketingis false for minors, so no later settings screen may turn marketing on for them. - An adult’s answer leaves both at their opt-in default.
Deleting a blocked user’s data at once
Section titled “Deleting a blocked user’s data at once”- For an under-13,
recordAgedeletes theuserrow in the same transaction as the check. Sessions, OAuth accounts,account_linksand chess.com request budgets cascade (ADR-WEB-3, ADR-WEB-5). - It also deletes every other copy of the email address: the
invitesrow and themagic_link_sendsthrottle log. This also means an invite given to a child does not stay usable from another browser. An address in theINVITE_ALLOWLISTenvironment variable cannot be removed by the app; the owner removes it. - The shared
linked_accountsrows stay. They describe public platform accounts that other users may link too, and they hold nothing the child gave us. - Nothing about the child is kept, not even the fact of the block, apart from the cookie in their own browser.
The 30-day block cookie
Section titled “The 30-day block cookie”POST /api/agesetsci_age_block=1; Max-Age=2592000; Path=/; HttpOnly; SameSite=Lax(plusSecurewhenever the session cookies are Secure, that is over https) and clears the session cookies (ci.session_token,ci.session_data,ci.dont_remember, or their__Secure-forms).- A Better Auth
beforehook refuses/sign-in/*,/sign-up/*,/magic-link/*,/oauth2/*and/callback/*with 403AGE_BLOCKEDwhile the cookie is present. It runs before the endpoint, so no magic link is mailed./callback/*(Google’s callback) is added to the brief’s list as defence in depth; the social sign-in that would lead there is already refused at/sign-in/social. - Why: without it, the back button or another provider would let the same child answer again with a different year straight away. The cookie is essential for that purpose. It holds no identifier, only
1. - It is a speed bump, not proof of age. Clearing cookies defeats it, as any self-declared age gate can be defeated.
No cookie banner
Section titled “No cookie banner”- The app sets only essential cookies: the session, the OAuth state and the age block. None is used for analytics or advertising, so no consent banner is needed (spec §14).
Route conventions
Section titled “Route conventions”POST /api/ageusesrejectCrossSitelike the Task 19 routes (403invalid_origin, 415unsupported_media_type), before reading the session.- It is the one route a signed-in user may call before the age is known, so it reads the session itself (401
unauthenticated, the same body asrequireApiUser) instead of callingrequireApiUser, which would answer 403age_required.
Deferred
Section titled “Deferred”- The DPIA and the review of nudges and dark patterns stay in M7.
/api/auth/magic-link/verifyanswers a blocked browser with the 403 JSON body. Task 21 should map it to/blocked, asmapAuthResponsedoes fornot_invited.
Consequences
Section titled “Consequences”- An under-13 who answers honestly leaves no account data behind, and cannot sign straight back in from the same browser.
- A recorded age cannot be corrected by the user. A mistaken answer needs the owner (support) to fix it in the database, which is acceptable for the beta.