9
2
Fork
You've already forked platform
2

Add legal doc versioning and ToS/Privacy consent tracking #153

Manually merged
anton merged 5 commits from add-tos-consent-checkbox into main 2026年04月09日 20:03:46 +02:00

What this does

Tracks which Terms of Service version each user accepted and which Privacy Notice version they acknowledged, starting at signup. This is the backend foundation for a future UI that will prompt users to re-accept when we publish updated legal documents.

User flow (not built yet, this PR is backend only)

  1. User signs up → backend records "accepted TOS v2026-02-12" and "acknowledged Privacy Notice v2026-04-03"
  2. We publish a new TOS → ops runs ./utils/admin activate-legal-doc <id>
  3. Next time the user loads the app, /api/user/status returns requires_action: true for that document
  4. Frontend (future PR) shows a modal → user clicks accept → POST /api/legal/accept records it → requires_action clears

What's in this PR

Database (024_legal_documents.sql):

  • legal_documents table — versioned registry of TOS and Privacy Notice with one-active-per-type constraint
  • user_legal_events table — append-only audit trail of all acceptance/acknowledgment events
  • CHECK constraints on document_type, event_type, event_source

Gateway (db.rs, handlers.rs):

  • User creation + legal event recording wrapped in a single transaction — no account without consent records
  • Captures IP and user-agent at signup

API (legal.rs, onboarding.rs, main.rs):

  • /api/user/status now includes a legal field with per-document active version, user's latest version, and requires_action
  • POST /api/legal/accept — re-acceptance endpoint for when we update legal documents

Admin tooling (utils/admin):

  • list-legal-docs, add-legal-doc, activate-legal-doc, user-legal-status

Tests (tests/e2e/test_legal_tracking.sh, unit tests in legal.rs)

Frontend (CSS/HTML only):

  • Split "Already have an account?" into its own element, removed ~160 lines of dead CSS

What's NOT in this PR

  • No modal/banner UI
  • No middleware gating (blocking API access until re-acceptance)
  • No backfill for existing users — they get requires_action: false
# What this does Tracks which Terms of Service version each user accepted and which Privacy Notice version they acknowledged, starting at signup. This is the backend foundation for a future UI that will prompt users to re-accept when we publish updated legal documents. # User flow (not built yet, this PR is backend only) 1. User signs up → backend records "accepted TOS v2026-02-12" and "acknowledged Privacy Notice v2026-04-03" 2. We publish a new TOS → ops runs `./utils/admin activate-legal-doc <id>` 3. Next time the user loads the app, `/api/user/status` returns `requires_action: true` for that document 4. Frontend (future PR) shows a modal → user clicks accept → `POST /api/legal/accept` records it → `requires_action` clears # What's in this PR Database (`024_legal_documents.sql`): - `legal_documents` table — versioned registry of TOS and Privacy Notice with one-active-per-type constraint - `user_legal_events` table — append-only audit trail of all acceptance/acknowledgment events - CHECK constraints on document_type, event_type, event_source Gateway (db.rs, handlers.rs): - User creation + legal event recording wrapped in a single transaction — no account without consent records - Captures IP and user-agent at signup API (`legal.rs`, `onboarding.rs`, `main.rs`): - `/api/user/status` now includes a legal field with per-document active version, user's latest version, and requires_action - `POST /api/legal/accept` — re-acceptance endpoint for when we update legal documents Admin tooling (utils/admin): - `list-legal-docs`, `add-legal-doc`, `activate-legal-doc`, `user-legal-status` Tests (`tests/e2e/test_legal_tracking.sh`, unit tests in `legal.rs`) Frontend (CSS/HTML only): - Split "Already have an account?" into its own element, removed ~160 lines of dead CSS # What's NOT in this PR - No modal/banner UI - No middleware gating (blocking API access until re-acceptance) - No backfill for existing users — they get requires_action: false
xenushka changed title from (削除) WIP: added tos consent, updated copy on login and registration pages (削除ここまで) to added tos consent, updated copy on login and registration pages 2026年04月07日 06:16:13 +02:00
xenushka changed title from (削除) added tos consent, updated copy on login and registration pages (削除ここまで) to Add legal doc versioning and ToS/Privacy consent tracking 2026年04月09日 00:59:14 +02:00
@ -0,0 +34,4 @@
event_sourceVARCHAR(50)NOTNULL,
CONSTRAINTchk_user_legal_events_doc_typeCHECK(document_typeIN('terms_of_service','privacy_notice')),
CONSTRAINTchk_user_legal_events_event_typeCHECK(event_typeIN('accepted','acknowledged','declined','notice_shown')),
Owner
Copy link

Users should not be able to decline documents in the case of ToS and Privacy Policy, these are not cookies. if you don't agree with the ToS you don't get to use the platform. Similar logic applies to acknowledged

Users should not be able to `decline` documents in the case of ToS and Privacy Policy, these are not cookies. if you don't agree with the ToS you don't get to use the platform. Similar logic applies to `acknowledged`
anton manually merged commit ddbba7a2cb into main 2026年04月09日 20:03:45 +02:00
Sign in to join this conversation.
No reviewers
Labels
Clear labels
Compat/Breaking
Breaking change that won't be backward compatible
Component/Enclave-Builder
This issue affects Enclave Builder (git-push and CLI)
Component/Infrastructure
This issue affects generic Caution hosted infra components
Deploy/BYOC
Relates to Caution Bring-your-own-compute
Deploy/Full-managed
Relates to Caution fully managed cloud
Deploy/Self-hosted
Relates to Caution deployed on self-hosted infra
Interface/API
This issue affects the API
Interface/CLI
This issue affects the command line interface
Interface/Git
This issue affects the Git `push` interface
Interface/Web
This issue affects the web dashboard
Kind/Bug
Something is not working
Kind/Documentation
Documentation changes
Kind/Enhancement
Improve existing functionality
Kind/Feature
New functionality
Kind/Security
This is security issue
Kind/Testing
Issue or pull request related to testing
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
caution/platform!153
Reference in a new issue
caution/platform
No description provided.
Delete branch "add-tos-consent-checkbox"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?