feat(account): full account deletion (GDPR / Play + Apple compliance)#388
Merged
Conversation
Add DELETE /me/account — transactional cascade delete of all user data (books/files/chapters, progress, bookmarks, highlights, vocab+reviews, sessions/goals/achievements, collections, avatar, refresh/reset tokens) + best-effort disk cleanup (logged on failure). Audit telemetry user_id set NULL (non-PII retention). Rate-limited 3/5min. Web: profile Danger zone -> type-DELETE confirm -> logout+redirect; public /delete-account info page. Mobile: profile Danger zone -> two-step Alert -> signOut. Stale access token accepted as bounded risk (refresh cascade-deleted, <=60min TTL, no leakage). Tests: 2 backend integration, web unit (api + confirm-gating), 5 e2e. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Why
Google Play (and Apple) require apps with sign-in to let users delete their account + all data in-app. We had no such flow — a hard blocker for the Play Data safety declaration and production access. This adds it end-to-end.
What
Backend —
DELETE /me/account(auth, rate-limit 3/5min). Transactional cascade delete of every user-owned entity (books/files/chapters/ingestion jobs, reading progress, bookmarks, highlights, vocabulary + reviews + settings/clusters, reading sessions/goals/achievements, library/collections, refresh & password-reset tokens) + best-effort disk cleanup (avatar + user storage dir), now logged on failure instead of swallowed. Audit telemetry (LlmTrace/ShadowRun/AgentRun/DeviceAuthorization) →user_id = NULL(non-PII retention). No migration (relies on existing cascade FKs).Web — Profile → Edit profile → Danger zone → dialog requiring the user to type
DELETE→AuthContext.deleteAccount()→ clears session → redirect home. Public/:lang/delete-accountinfo page + footer link. i18n strings added.Mobile — Profile → Danger zone → two-step destructive
Alert→signOut()→ Home. Honors theme/dark mode; hidden for guests. (Also satisfies Apple's in-app deletion requirement.)Security note
A short-lived access JWT stays signature-valid after deletion. Treated as bounded, acceptable: refresh-token rows cascade-delete (no new tokens), access TTL ≤60min, no data leakage (owned data gone, reads empty, writes fail at FK). No per-request DB guard added (would tax the hot path). Documented; proper fix (revocation set / shorter TTL) noted if the threat model tightens.
Tests
tsc --noEmitclean.Verify after merge
/delete-accountpage + endpoint.🤖 Generated with Claude Code