Skip to content

Privacy & Data Control - account deletion and data export#437

Open
atul-upadhyay-7 wants to merge 7 commits into
Priyanshu-byte-coder:mainfrom
atul-upadhyay-7:feature/privacy-data-control
Open

Privacy & Data Control - account deletion and data export#437
atul-upadhyay-7 wants to merge 7 commits into
Priyanshu-byte-coder:mainfrom
atul-upadhyay-7:feature/privacy-data-control

Conversation

@atul-upadhyay-7
Copy link
Copy Markdown

Implements privacy and data control features as requested in #380.

Features

  • Data Export - Download all user data as JSON (goals, metrics, settings, etc.)
  • Delete Account - Permanently delete all user data with confirmation
  • Privacy Settings - New section in dashboard settings

API Endpoints

  • GET /api/user/data-export - Export all user data
  • DELETE /api/user/data-export - Delete account with confirmation

Components

  • PrivacySettings component for dashboard settings

GDPR Compliance

  • Users can export all their data
  • Users can permanently delete their account
  • Transparency about what data is stored

- Add data export endpoint to download all user data as JSON
- Add account deletion endpoint with confirmation
- Add PrivacySettings component to dashboard settings
- Users can export their data or delete their account
- GDPR compliance and user data ownership
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

Someone is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the gssoc26 GSSoC 2026 contribution label May 20, 2026
@github-actions
Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

Required fixes before merge:

  1. Broken webhook_deliveries export query.eq('webhook_id', webhooks?.map(w => w.id) || []) passes an array to .eq() which expects a scalar. This silently returns zero rows. Change to .in('webhook_id', webhooks?.map(w => w.id) || []).

  2. Same bug in deletion — the tablesToDelete entry for webhook_deliveries uses .eq('user_id', user.id) but webhook_deliveries has no user_id column (only webhook_id). This is a no-op. The cascade via webhook_configs ON DELETE CASCADE handles this correctly, so remove the explicit webhook_deliveries entry from tablesToDelete.

  3. Hardcoded Tailwind colorsborder-green-500/30, bg-green-500/10, text-green-400, border-red-500/30, bg-red-500, hover:bg-red-600 in PrivacySettings.tsx. Use CSS variables per project convention.

  4. Missing EOF newlines on data-export/route.ts and PrivacySettings.tsx.

@Priyanshu-byte-coder Priyanshu-byte-coder added level:intermediate GSSoC: Intermediate difficulty (35 pts) type:feature GSSoC type bonus: new feature labels May 20, 2026
atul-upadhyay-7 and others added 2 commits May 21, 2026 08:49
- Fix broken webhook_deliveries export query: change .eq() to .in() for array matching
- Remove webhook_deliveries from tablesToDelete (handled by ON DELETE CASCADE)
- Replace hardcoded Tailwind colors with CSS variables (--success, --destructive)
- Add --destructive CSS variable to globals.css for both light and dark themes
- Add EOF newlines to data-export/route.ts and PrivacySettings.tsx
@github-actions github-actions Bot added the type:design GSSoC type bonus: UI/design (+10 pts) label May 21, 2026
@atul-upadhyay-7
Copy link
Copy Markdown
Author

Fixes Applied

Addressed all mentor review feedback:

1. Broken webhook_deliveries export query

  • Changed .eq('webhook_id', webhooks?.map(w => w.id) || []) to .in('webhook_id', webhookIds)
  • .eq() expects a scalar value, passing an array silently returned zero rows

2. Broken deletion query for webhook_deliveries

  • Removed webhook_deliveries from tablesToDelete array
  • webhook_deliveries has no user_id column (only webhook_id)
  • The ON DELETE CASCADE on webhook_configs handles this correctly

3. Hardcoded Tailwind colors replaced with CSS variables

  • border-green-500/30border-[var(--success)]/30
  • bg-green-500/10bg-[var(--success)]/10
  • text-green-400text-[var(--success)]
  • border-red-500/30border-[var(--destructive)]/30
  • bg-red-500/10bg-[var(--destructive)]/10
  • text-red-400text-[var(--destructive)]
  • bg-red-500bg-[var(--destructive)]
  • hover:bg-red-600hover:bg-[var(--destructive)]/90
  • Added --destructive CSS variable to globals.css for both light/dark themes

4. EOF Newlines

  • Added trailing newlines to src/app/api/user/data-export/route.ts
  • Added trailing newlines to src/components/PrivacySettings.tsx

…move unused interface

- Replace error message hardcoded red colors with --destructive CSS variable
- Remove unused DataStats interface from PrivacySettings.tsx
@atul-upadhyay-7
Copy link
Copy Markdown
Author

Additional Fixes Applied

After deep analysis against issue #380 requirements, found and fixed remaining gaps:

1. Error Message Colors

  • Replaced remaining hardcoded red colors in error messages with --destructive CSS variable
  • border-red-500/30border-[var(--destructive)]/30
  • bg-red-500/10bg-[var(--destructive)]/10
  • text-red-400text-[var(--destructive)]

2. Code Cleanup

  • Removed unused DataStats interface from PrivacySettings.tsx

Complete Issue #380 Coverage

Requirement Status
1. Data Export (JSON download) ✅ PASS
2. Delete Account (with confirmation) ✅ PASS
3. Profile Visibility toggles ⚠️ PARTIAL (DB fields exist, UI can be added later)
4. Data Retention policy ❌ OPTIONAL (marked as 'Maybe' in issue)

All Mentor Blockers Resolved

Blocker Status
Broken webhook_deliveries query ✅ RESOLVED
Broken deletion query ✅ RESOLVED
Hardcoded Tailwind colors ✅ RESOLVED
Missing EOF newlines ✅ RESOLVED

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

The account deletion calls DELETE /api/user/data-export but the data-export/route.ts file only implements the GET handler (data export). The DELETE method handler is missing — the deletion will return 405.

Please add an export async function DELETE() to src/app/api/user/data-export/route.ts (or a separate /api/user/delete-account route) that:

  1. Verifies the session
  2. Deletes the user's Supabase row (and cascade deletes via foreign keys)
  3. Invalidates the session

@atul-upadhyay-7
Copy link
Copy Markdown
Author

atul-upadhyay-7 commented May 21, 2026

@Priyanshu-byte-coder
All mentor feedback has been addressed. Here is a summary of what was done:

Review 1 (4 issues by Priyanshu-byte-coder):

  1. ✅ Fixed webhook_deliveries export query: .eq().in() for array matching
  2. ✅ Removed webhook_deliveries from tablesToDelete (handled by ON DELETE CASCADE)
  3. ✅ Replaced hardcoded Tailwind colors with CSS variables (--success, --destructive)
  4. ✅ Added EOF newlines to both files

Review 2 (DELETE handler by Priyanshu-byte-coder):
The DELETE handler was present in the initial implementation. However, three specific requirements were addressed:

  1. ✅ Verifies the session via getServerSession(authOptions)
  2. ✅ Deletes user data from all relevant tables (9 tables) + users table (cascade via foreign keys)
  3. NEW — Added session invalidation by clearing the NextAuth session cookie (next-auth.session-token)

Files changed:

  • src/app/api/user/data-export/route.ts (GET + DELETE with session invalidation)
  • src/components/PrivacySettings.tsx (Frontend UI with export/delete)
  • src/app/dashboard/settings/page.tsx (Integration)
  • src/app/globals.css (--destructive CSS variable)

This completes the privacy & data control feature requested in issue #380.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution level:intermediate GSSoC: Intermediate difficulty (35 pts) type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants