Skip to content

Commit 882b581

Browse files
committed
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. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CnAiFYkyMmyrtbd7GB46gY
1 parent c3afc9c commit 882b581

94 files changed

Lines changed: 6401 additions & 66 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.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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_users" ALTER COLUMN "ipAddress" DROP NOT NULL;--> statement-breakpoint
20+
CREATE UNIQUE INDEX "core_users_deletions_pending_user_unique" ON "core_users_deletions" ("userId") WHERE "status" = 'pending';--> statement-breakpoint
21+
CREATE INDEX "core_users_deletions_status_scheduled_idx" ON "core_users_deletions" ("status","scheduledAt");--> statement-breakpoint
22+
CREATE INDEX "core_users_deletions_erased_user_idx" ON "core_users_deletions" ("erasedUserId");--> statement-breakpoint
23+
CREATE INDEX "core_users_deletions_created_at_id_idx" ON "core_users_deletions" ("createdAt","id");--> statement-breakpoint
24+
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
25+
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)