Remove the invite and sign-in log entries when an account is deleted

Đang mở
#359 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
nextjs, postgresql, supabase, typescript

Hướng nghiên cứu

Start at deleteUserAccount in src/lib/data/account.ts (around line 222) and read it next to removeSyntheticUser in e2e/fixtures/auth.ts, which shows the manual invite cleanup to fold in. Read the public.access_invites definition in supabase/migrations/20261031090300_jobs_and_invites.sql and copy the batching pattern from the existing purges in src/lib/jobs/retention.ts for the auth.audit_log_entries sweep, which needs a service-role SQL function since auth is not exposed to PostgREST. Done means both unit cases pass, npx supabase test db covers deleted and surviving users, and the privacy page, PRIVACY_UPDATED, docs/architecture/schema.md and scripts/invite.ts agree.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area: auth enhancement impact: medium priority: P2 size: S

Summary

Deleting an account leaves two records that hold the person's email address: their row on the invite list and Supabase Auth's log of sign-in events. The privacy policy from #339 (pull request #349, review round 2) now says so and tells people to email the operator to have them removed. This issue makes deletion remove them instead, so the policy can say "deleting your account removes everything".

Found by review round 2 of #349 (inline comment https://github.com/eddiejaoude/DevMacro/pull/349#discussion_r4548534055).

Evidence

  • deleteUserAccount (src/lib/data/account.ts:222) calls auth.admin.deleteUser and nothing else.
  • public.access_invites (supabase/migrations/20261031090300_jobs_and_invites.sql:116) keys on the email with no foreign key to auth.users, so the row stays. scripts/invite.ts:9 documents removal as a separate manual step, and e2e/fixtures/auth.ts (removeSyntheticUser) deletes the invite by hand after deleting the user.
  • auth.audit_log_entries keeps every sign-up, sign-in, refresh, sign-out, and deletion event with the email in payload.actor_username. Nothing in src/lib/jobs/retention.ts, the migrations, or supabase/config.toml deletes rows from it.
  • Reproduced on the local stack with a synthetic user (legal-probe-*@example.com): after auth.admin.deleteUser, auth.sessions held 0 rows for the user, public.access_invites still held 1 row for the email, and auth.audit_log_entries held 7 rows naming the email (login, logout, token_refreshed, token_revoked, user_deleted, user_signedup), none with an ip_address.
  • Hosted: Supabase writes the audit log to its own log storage always, and to auth.audit_log_entries only while Authentication, Audit Logs, Write audit logs to the database is on (https://supabase.com/docs/guides/auth/audit-logs). The hosted project's setting has not been checked.

Scope

  • deleteUserAccount deletes the account's access_invites row (by its lowercased email, read before the user is deleted) once auth.admin.deleteUser succeeds. A failure there is logged with a reference id and does not undo the deletion. A person who deletes their account then needs a new invite to come back, which matches "deleting removes everything".
  • The daily retention job (src/lib/jobs/retention.ts) deletes auth.audit_log_entries rows whose payload->>'actor_id' no longer exists in auth.users, in batches like the other purges, through a service role database function (the auth schema is not exposed to PostgREST).
  • Update the privacy policy (src/app/privacy/page.tsx: the invite item, the retention items, and the deletion paragraph), PRIVACY_UPDATED, docs/architecture/schema.md, and scripts/invite.ts's comment to match.
  • Not in scope: Supabase's own copy of the audit log in its log storage, which the app cannot delete; the policy keeps saying Supabase holds it for the period its service sets.

Acceptance criteria

  • Deleting an account removes its invite row (unit test for the happy path and for the invite delete failing after the user is gone).
  • The retention job removes audit log entries of deleted users and keeps those of existing users (database test with npx supabase test db, both cases).
  • The privacy policy no longer lists the invite row or the database audit log among what survives deletion.
  • e2e/fixtures/auth.ts no longer deletes the invite by hand where the app now does it.

Model: anthropic/claude-opus-5-5 | Reasoning effort: unknown

Ngôn ngữ chính
TypeScript
Star
1
Fork
1
Merge trung bình
6 giờ 56 phút
Pull request đã merge (30 ngày)
136

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của eddiejaoude/StackDash

Tất cả issue của eddiejaoude/StackDash

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.