Skip to content

feat(users): ✨ GDPR account deletion and personal data export - #928

Merged
aXenDeveloper merged 1 commit into
canaryfrom
claude/confident-goodall-r1ed89
Nov 21, 2026
Merged

aXenDeveloper merged 1 commit into
canaryfrom
claude/confident-goodall-r1ed89

Conversation

@aXenDeveloper

Copy link
Copy Markdown
Owner
  • Settings → Privacy & data: download a JSON copy of your data and delete
    your account (password or recent sign-in, grace period, cancel anytime)
  • definePersonalData / personalData on buildApiPlugin so plugins
    export and erase their own rows; core handles its tables
  • Erasure: revokes sessions, deletes uploaded files, runs every plugin's
    erase and deletes the account in one transaction, emits user.deleted
  • Hourly account-deletion cron with retries; failures recorded on the
    request
  • AdminCP: Delete account card on the user page (schedule or delete now),
    Users → Account deletions list with retry/cancel, users:can_delete
  • core_users_deletions keeps a tombstone of each request as proof
  • Daily ip-retention cron (users.ipRetentionDays, default 180)
  • New events user.deletion.requested / user.deletion.cancelled;
    user.deleted is now emitted
  • Emails, EN + PL translations and docs

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01CnAiFYkyMmyrtbd7GB46gY

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T17:22:09.232499Z 0171318 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the 💡 Feature A new feature label Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

React Doctor found 10 new issues in 8 files · 10 warnings · score 88 / 100 (Great) · 0 fixed · vs canary

10 warnings

src/lib/account-deletion/erase.ts

  • ⚠️ L67 await inside a loop async-await-in-loop
  • ⚠️ L152 await inside a loop async-await-in-loop

src/lib/account-deletion/ip-retention.ts

  • ⚠️ L38 Independent awaits run sequentially async-parallel
  • ⚠️ L56 Sequential independent awaits server-sequential-independent-await

src/modules/admin/users/routes/deletions.route.ts

  • ⚠️ L31 Array lookup inside a loop js-set-map-lookups

src/modules/users/routes/personal-data.route.ts

  • ⚠️ L35 await inside a loop async-await-in-loop

src/views/admin/views/core/debug/sections/privacy-requests.tsx

  • ⚠️ L135 Heading has no content heading-has-content

src/views/admin/views/core/users/deletions/deletions-attention.tsx

  • ⚠️ L40 Heading has no content heading-has-content

src/views/admin/views/core/users/detail/user-devices-sheet.tsx

  • ⚠️ L61 Array lookup inside a loop js-set-map-lookups

src/views/admin/views/core/users/detail/user-profile-cards.tsx

  • ⚠️ L75 Heading has no content heading-has-content

Reviewed by React Doctor for commit 0171318. See inline comments for fixes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa1f151cfc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +261 to +264
const result = await eraseAccount(c, {
deletionId,
userId: row.userId,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Apply target-account permission checks before retrying erasure

An administrator with users.canDelete can use this endpoint to immediately erase a pending or failed request for a higher-privileged staff account, even without can_edit_admin or the target's permission ceiling. Unlike deleteUserAdminRoute, this handler never calls assertCanEditAdminTarget or rejects the caller's own account before invoking eraseAccount. A request previously scheduled by a more privileged administrator therefore provides a bypass around the direct deletion endpoint's protections. Resolve and authorize the target before changing the request or running erasure.

Useful? React with 👍 / 👎.

Comment on lines +139 to +144
let files = { deleted: 0, kept: 0 };
try {
await revokeSessions(c, { userId });
files = await deleteUserFiles(c, userId);

await db.transaction(async tx => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Coordinate cancellation with the erasure worker

If a member cancels after processDueAccountDeletions selects its batch but before their account is processed, cancellation returns success, yet eraseAccount still deletes their files and account. The worker retains the selected IDs, and this update unconditionally overwrites the now-cancelled request with completed. This window also includes time spent erasing earlier accounts in the batch. Atomically claim or lock the request in coordination with cancellation, and verify it is still eligible before performing destructive side effects.

Useful? React with 👍 / 👎.

Comment on lines +239 to +241
await tx
.update(core_audit_logs)
.set({ targetLabel: null })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove historical account names from retained audit changes

For an account whose name or handle was edited in the AdminCP, clearing targetLabel does not anonymize the retained audit entries: adminUserAuditChanges explicitly preserves name and nameCode values, and updateUserAdminRoute stores them in core_audit_logs.changes. Those old and new names remain readable and linked to the erased user ID after this handler completes. Redact the identifying fields in the retained changes as well as the label so account erasure actually stops these records from naming the member.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f458f74b15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.where(
and(
eq(core_users_deletions.id, deletionId),
eq(core_users_deletions.status, "pending"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow administrators to cancel failed deletion requests

Once an erasure reaches five failed attempts, this predicate makes the AdminCP's Cancel deletion action always return 404. Both UserDeleteCard and AccountDeletionActions offer cancellation for failed requests, and the underlying cancelAccountDeletion helper already accepts both pending and failed, but this preliminary lookup excludes the latter. Consequently, staff cannot cancel a failed request to restore the account's visibility without first retrying the destructive operation. Accept both open statuses here.

Useful? React with 👍 / 👎.

Comment on lines +229 to +231
erase: async ({ tx, userId }) => {
// Debug logs exist for operators, not as a record of the member.
await tx.delete(core_logs).where(eq(core_logs.userId, userId));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Anonymize authors embedded in retained moderation snapshots

When the erased member authored reported content, their ID and name remain in core_moderation_reports.snapshot.authors: content/server/report-target.ts explicitly copies both into the snapshot, and deleting core_users cannot clear these JSON values. The report-detail API returns the snapshot unchanged, and report-content.tsx even falls back to that saved name when the live author no longer exists, so moderators continue seeing the erased identity after successful erasure. Redact matching snapshot authors in this core erasure handler while retaining the report's content.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f77f3ce14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +61 to +64
await c
.get("storage")
.deleteFile(file.id, { force: true, ownerId: userId });
deleted++;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Persist failed storage deletions before completing erasure

If the storage provider fails while deleting an upload, StorageModel.deleteFile removes the core_files row first and suppresses the provider's deletion error (packages/api/src/models/storage.ts:550–558). This call therefore counts the file as deleted and lets account erasure complete even though its bytes remain stored—and public uploads remain accessible at their existing URLs. Since the file row is already gone and the request is completed, subsequent erasure runs cannot discover or retry that object. Use a deletion path that durably records failed object removals and retries them rather than treating this best-effort operation as confirmed erasure.

Useful? React with 👍 / 👎.

@aXenDeveloper
aXenDeveloper force-pushed the claude/confident-goodall-r1ed89 branch 2 times, most recently from 882b581 to 035769a Compare November 20, 2026 19:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 035769ac06

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

})
.where(eq(core_users_deletions.id, deletionId));

await tx.delete(core_users).where(eq(core_users.id, userId));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reconcile reaction totals before cascading account deletion

When an erased member has reacted to other members' content, deleting core_users cascades to core_reactions_entries without updating core_reactions_counts or the recipients' core_users.reputation. Unlike removeReaction in lib/reactions/service.ts, this path never applies the corresponding count and reputation deltas, so retained content displays reactions that no longer exist and surviving authors keep the deleted reactions' points. The reactions cleanup cron only reconciles deleted content targets, so it does not repair this case. Remove the member's reactions and reconcile their aggregates within the erasure transaction before deleting the account.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e2831a68e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +78 to +81
const deletion = await findOpenAccountDeletion(c, payload.u);
if (deletion?.id !== payload.d) return null;

if (!(await cancelAccountDeletion(c, payload.u))) return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Invalidate held sign-ins when credentials are reset

If someone obtains a password-based deletion-hold token and the account owner resets their password before that token expires, the token still cancels deletion and creates a fresh session for its holder. change-password.route.ts explicitly revokes existing sessions after a reset, and the normal password sign-in path uses revokeIfPasswordChanged to prevent authentication with stale credentials, but this release path checks only the token's expiry and deletion ID. Consequently, a holder of the old credentials can regain access for up to ten minutes after the owner's reset. Bind held authentication to revocable authentication state and verify it before cancelling the request or issuing a session.

Useful? React with 👍 / 👎.

Members download their data and delete their account from Settings →
Privacy & data; staff delete accounts from the AdminCP; the Debug Panel
tracks every request against GDPR's one-month limit.

API (@vitnode/api)
- core_users_deletions: request tombstone (pending, completed, cancelled,
  failed) that outlives the account; one open request per user.
- definePersonalData + buildApiPlugin `personalData`: plugins export and
  erase their own rows; core handles its tables (logs, audit, payments).
- Erasure: revoke sessions, delete files, run every plugin's erase and
  delete the user in one transaction, then emit user.deleted and email a
  goodbye. Failures are recorded and retried hourly up to five times.
- Member routes: GET/POST/DELETE /me/account-deletion (password or recent
  sign-in), GET /me/personal-data. Profiles of accounts being deleted 404.
- Admin routes: delete a user (scheduled or immediately), list, summary,
  retry and cancel requests; users list `deletion` filter and badge data.
  All need the new users:can_delete staff permission.
- Roles: allowDeleteAccount (default on) gates self-deletion.
- Cron: account-deletion (hourly) and ip-retention (daily).
- Config: users.accountDeletion.graceDays (14, max 30) and
  users.ipRetentionDays (180). users.ipAddress is nullable.
- Events: user.deletion.requested, user.deletion.cancelled; user.deleted
  is now emitted. Audit actions and scheduled/deleted emails.

UI (@vitnode/core)
- Settings → Privacy & data with download and a red danger zone.
- DangerZone component; user page danger zone with delete (optionally
  immediately), cancel and retry.
- Users list deletion badge and filter; role form switch.
- Debug Panel: Account deletions tab (checks, needs you, all requests
  with a details sheet) and a Privacy requests card on the Overview.

Docs: Account Deletion and Data Export, Export and Erase Plugin Data,
built-in events. EN and PL locales.

Deletion hold (sign-in during the grace period)
- AccountDeletionHold: signing in to an account pending deletion shows a
  countdown instead of a session; the member can cancel the deletion with
  a signed token (zod-validated) and continue, or leave it scheduled.
- requestAccountDeletion returns scheduledAt; SSO callbacks report a
  deletion_pending state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aXenDeveloper
aXenDeveloper force-pushed the claude/confident-goodall-r1ed89 branch from b3713fc to 0171318 Compare November 21, 2026 17:19
let kept = 0;
for (const file of files) {
try {
await c

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/async-await-in-loop (warning)

This for…of loop waits before starting the next iteration. If iterations perform independent asynchronous work, consider bounded concurrency; await syntax alone does not establish a speedup.

Fix → Consider concurrent calls only for independent asynchronous work. Shared queues or synchronous work may not benefit. Preserve resource limits, transaction ordering, and failure/cancellation semantics; observe all callback promises.

Docs


await db.transaction(async tx => {
for (const entry of c.get("core").personalData) {
await entry.erase?.({ c, tx, userId });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/async-await-in-loop (warning)

This for…of loop waits before starting the next iteration. If iterations perform independent asynchronous work, consider bounded concurrency; await syntax alone does not establish a speedup.

Fix → Consider concurrent calls only for independent asynchronous work. Shared queues or synchronous work may not benefit. Preserve resource limits, transaction ordering, and failure/cancellation semantics; observe all callback promises.

Docs


const cutoff = new Date(now.getTime() - retentionDays * 86_400_000);

const logs = await inBatches(async () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/async-parallel (warning)

These 3 sequential await statements run one after another even though they look independent, so the page waits longer than it needs to. Run them together with Promise.all() instead

Fix → Use const [a, b] = await Promise.all([fetchA(), fetchB()]) so independent calls run at the same time

Docs

return rows.length;
});

const activityLogs = await inBatches(async () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/server-sequential-independent-await (warning)

This awaited initializer does not read the previous result. If the operations are independent asynchronous work, they may overlap; await syntax alone does not establish a speedup.

Fix → Consider Promise.all([...]) only for independent asynchronous work. Shared queues or synchronous work may not benefit. Preserve resource limits, transaction ordering, and failure/cancellation semantics.

Docs

known: readonly T[],
): T[] =>
(raw?.split(",") ?? []).filter((value): value is T =>
(known as readonly string[]).includes(value),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/js-set-map-lookups (warning)

This scales poorly because array.includes() inside a loop scans the whole list every time. Use a Set for constant-time lookups.

Fix → Use a Set or Map when you check for the same items over and over. Array.includes/find scans the whole list each time

Docs

const plugins: Record<string, Record<string, unknown>> = {};
for (const entry of c.get("core").personalData) {
if (!entry.export) continue;
plugins[entry.pluginId] = await entry.export({ c, userId: user.id });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/async-await-in-loop (warning)

This for…of loop waits before starting the next iteration. If iterations perform independent asynchronous work, consider bounded concurrency; await syntax alone does not establish a speedup.

Fix → Consider concurrent calls only for independent asynchronous work. Shared queues or synchronous work may not benefit. Preserve resource limits, transaction ordering, and failure/cancellation semantics; observe all callback promises.

Docs

return (
<Frame render={<section aria-labelledby="privacy-requests-title" />}>
<FrameHeader>
<FrameTitle id="privacy-requests-title" render={<h2 />}>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/heading-has-content (warning)

Blind users can't use this heading to navigate because screen readers skip it empty, so add text, aria-label, or aria-labelledby.

Fix → Put readable text in every heading.

Docs

<FrameTitle
className="flex items-center gap-2"
id="deletions-attention-title"
render={<h3 />}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/heading-has-content (warning)

Blind users can't use this heading to navigate because screen readers skip it empty, so add text, aria-label, or aria-labelledby.

Fix → Put readable text in every heading.

Docs

];

const matchesKinds = (device: AdminUserDevice, kinds: SessionKind[]) =>
kinds.length === 0 || kinds.some(kind => device.sessionKinds.includes(kind));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/js-set-map-lookups (warning)

This scales poorly because array.includes() inside a loop scans the whole list every time. Use a Set for constant-time lookups.

Fix → Use a Set or Map when you check for the same items over and over. Array.includes/find scans the whole list each time

Docs

<FrameTitle
className="flex items-center gap-2"
id={titleId}
render={<h2 />}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/heading-has-content (warning)

Blind users can't use this heading to navigate because screen readers skip it empty, so add text, aria-label, or aria-labelledby.

Fix → Put readable text in every heading.

Docs

@aXenDeveloper
aXenDeveloper merged commit 5c545c2 into canary Nov 21, 2026
7 checks passed
@aXenDeveloper
aXenDeveloper deleted the claude/confident-goodall-r1ed89 branch November 21, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💡 Feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant