Skip to content

Commit 0171318

Browse files
aXenDeveloperclaude
andcommitted
feat(users): ✨ GDPR account deletion and personal data export
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>
1 parent 5f6b84e commit 0171318

141 files changed

Lines changed: 8509 additions & 725 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { Activity } from "react";
2727
</Activity>;
2828
```
2929

30+
- Always use skeletons for loading feedback. Use `<Loader />` only if its necessary.
3031
- Add a breadcrumb with the route's `staticData.breadcrumb`; a crumb that renders strings needs its own `RouteMessages`.
3132
- Route files are topology only - `validateSearch`, `loaderDeps`, `loader`, `head`, `staticData`. The query, the permissions, the namespaces and the screen live in `@vitnode/core/tanstack/*`.
3233
- Write `head` **after** `loader` in the same object literal: `loaderData` is inferred from `loader`, and TypeScript reads members in order.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CREATE TABLE "core_users_deletions" (
2+
"id" serial PRIMARY KEY,
3+
"userId" integer,
4+
"erasedUserId" integer NOT NULL,
5+
"source" varchar(16) NOT NULL,
6+
"requestedById" integer,
7+
"status" varchar(16) DEFAULT 'pending' NOT NULL,
8+
"scheduledAt" timestamp NOT NULL,
9+
"attempts" integer DEFAULT 0 NOT NULL,
10+
"lastError" text,
11+
"filesDeleted" integer DEFAULT 0 NOT NULL,
12+
"filesKept" integer DEFAULT 0 NOT NULL,
13+
"createdAt" timestamp DEFAULT now() NOT NULL,
14+
"cancelledAt" timestamp,
15+
"completedAt" timestamp
16+
);
17+
--> statement-breakpoint
18+
ALTER TABLE "core_users_deletions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
19+
ALTER TABLE "core_roles" ADD COLUMN "allowDeleteAccount" boolean DEFAULT true NOT NULL;--> statement-breakpoint
20+
ALTER TABLE "core_users" ALTER COLUMN "ipAddress" DROP NOT NULL;--> statement-breakpoint
21+
CREATE UNIQUE INDEX "core_users_deletions_pending_user_unique" ON "core_users_deletions" ("userId") WHERE "status" = 'pending';--> statement-breakpoint
22+
CREATE INDEX "core_users_deletions_status_scheduled_idx" ON "core_users_deletions" ("status","scheduledAt");--> statement-breakpoint
23+
CREATE INDEX "core_users_deletions_erased_user_idx" ON "core_users_deletions" ("erasedUserId");--> statement-breakpoint
24+
CREATE INDEX "core_users_deletions_created_at_id_idx" ON "core_users_deletions" ("createdAt","id");--> statement-breakpoint
25+
ALTER TABLE "core_users_deletions" ADD CONSTRAINT "core_users_deletions_userId_core_users_id_fkey" FOREIGN KEY ("userId") REFERENCES "core_users"("id") ON DELETE SET NULL;--> statement-breakpoint
26+
ALTER TABLE "core_users_deletions" ADD CONSTRAINT "core_users_deletions_requestedById_core_users_id_fkey" FOREIGN KEY ("requestedById") REFERENCES "core_users"("id") ON DELETE SET NULL;

0 commit comments

Comments
 (0)