feat: add signup consent gate and record acceptance - #181
Merged
Conversation
ZeyNor
force-pushed
the
feat/pyz-296-publish-sub-processor-list-and-change
branch
from
July 10, 2026 20:52
173c84b to
fa6122b
Compare
ZeyNor
force-pushed
the
feat/pyz-293-add-signup-consent-gate-and-record
branch
from
July 10, 2026 20:54
b35c19b to
8ef8b55
Compare
ZeyNor
force-pushed
the
feat/pyz-296-publish-sub-processor-list-and-change
branch
from
July 10, 2026 21:41
fa6122b to
ab9256c
Compare
ZeyNor
force-pushed
the
feat/pyz-293-add-signup-consent-gate-and-record
branch
from
July 10, 2026 21:41
8ef8b55 to
15f1d8a
Compare
Repository owner
deleted a comment from
ZeyNor
Jul 10, 2026
ZeyNor
force-pushed
the
feat/pyz-296-publish-sub-processor-list-and-change
branch
from
July 10, 2026 22:35
ab9256c to
cad86af
Compare
ZeyNor
force-pushed
the
feat/pyz-293-add-signup-consent-gate-and-record
branch
from
July 10, 2026 22:35
15f1d8a to
c3fdad8
Compare
ZeyNor
force-pushed
the
feat/pyz-296-publish-sub-processor-list-and-change
branch
from
July 11, 2026 06:41
cad86af to
921389c
Compare
ZeyNor
force-pushed
the
feat/pyz-293-add-signup-consent-gate-and-record
branch
from
July 11, 2026 06:41
2a1b550 to
76b22e2
Compare
Base automatically changed from
feat/pyz-296-publish-sub-processor-list-and-change
to
main
July 11, 2026 06:43
FrkAk
approved these changes
Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Task Reference: [PYZ-293]
Add affirmative Terms-of-Service consent to email/password signup and persist compliance evidence.
SignUpFormgains one unchecked Terms checkbox linking/termsand a Privacy acknowledgement link to/privacy. Every account creation is gated server-side on Terms acceptance via auser.create.beforehook inlib/auth.ts, so a direct POST to/api/auth/sign-up/emailthat omits acceptance is rejected, not just the form. On success auser.create.afterhook writes twolegal_acceptancesrows (oneterms, oneprivacy), each with the pinnedLEGAL_VERSIONSversion, timestamp, resolved client IP, and user-agent.Builds on the PYZ-291 storage/versioning primitive (
recordAcceptance,LEGAL_VERSIONS,legal_acceptancestable). No schema change here.Type of change
Testing
bun run devbun run lint)bun run typecheck)New
tests/auth/signup-consent.test.tscovers: signup without acceptance is rejected and writes no user or rows; signup with acceptance creates the user and exactly two acceptance rows carrying the correct version, timestamp, resolved IP, and user-agent; and IP resolution from the firstx-forwarded-forentry. Verified viabun test tests/auth/ tests/actions/ tests/security/list-invitations-bypass.test.ts(all green) rather than the dev server.Notes for reviewer
databaseHooks.user.create.before(throwsAPIError), so it fires forauth.api.signUpEmailand raw POSTs alike; the client checkbox is UX, not the boundary. Acceptance rows are written inafterbecause they FK the user row, which does not exist until creation commits.termsAccepteddelivery (columnless). Read offctx.bodyin the hook, kept a transient consent signal with no persistedpiyaz_auth.usercolumn or migration (the durable evidence is thelegal_acceptancesrows). The typedsignUp.email/signUpEmailbody does not declaretermsAccepted, so callers pass the body as a typed variable (structural width-subtyping) rather than an inline literal; this is why the existing test signup call sites were adjusted.user.create.afterdoes not roll back the committed user. To avoid an account with no acceptance evidence, theafterhook logs and runs a compensatinginternalAdapter.deleteUserbefore re-throwing.recordAcceptanceAPI, which opens its ownwithUserContexttransaction per call. Literal single-transaction atomicity across user creation plus both rows is out of scope (would require refactoring PYZ-291's API).app/(auth)/sign-up/page.tsxstill carries a passive "By creating an account you agree to our Terms and Privacy Policy" footer. It was left untouched (outside this task's file scope) but now overlaps the affirmative in-form checkbox; consider consolidating.feat/pyz-296-...; the/termsand/privacylink targets land with PYZ-292 on the same stack.Docs impact
none