Skip to content

Preview deletion impact before approving an account-deletion request - #177

Merged
xusheng6 merged 1 commit into
mainfrom
feature/account-deletion-preview
Jul 26, 2026
Merged

Preview deletion impact before approving an account-deletion request#177
xusheng6 merged 1 commit into
mainfrom
feature/account-deletion-preview

Conversation

@xusheng6

Copy link
Copy Markdown
Contributor

Summary

Two things were asked:

  1. Is "review & approve delete account" admin-only?Yes, already. The approveaccountdeletion route carries @admin_required (403s for non-admins), and the queue template only renders the approve button for admins. No change needed there; this PR keeps that guard intact. (Listing and rejecting requests remain open to any reviewer, as before.)

  2. Preview the deletion effect during approval, the same way the manual delete-account tool does — this is the substance of the PR.

Problem

Approving a self-service deletion request used to run the full, irreversible delete_user_account() straight from the queue, gated only by a JS confirm() popup. The admin saw nothing about what would actually be removed. The manual /deleteuser tool, in contrast, shows a detailed impact preview (the account, its crackmes, cascaded solutions/comments/ratings, notifications, and totals) before a final confirmation.

Change

  • Two-step approval mirroring the manual tool. The button (now "Review & approve deletion") POSTs to a first step that resolves the target account and renders the deletion-impact preview via the existing preview_user_deletion(). A second POST (action=confirm_delete) performs the deletion, marks the request approved, and emails the former user — the original logic, unchanged.
  • Shared partial reviewer/_deletion_preview.html extracted from deleteuser.html, so the manual tool and the approval flow render an identical breakdown (no drift). deleteuser.html now includes it too.
  • Approval stays @admin_required.

Testing

  • Updated test_admin_approves_deletion_and_emails_user to exercise both steps: first POST returns the preview (200) and deletes nothing; the confirm_delete POST deletes, marks approved, and sends the email.
  • test_non_admin_cannot_approve_deletion still 403s.
  • Full suite: 236 passed. All templates compile.

🤖 Generated with Claude Code

Approving a self-service account deletion previously ran the full,
irreversible deletion straight from the queue behind only a JS confirm()
dialog, showing the admin nothing about what would actually be removed.
The manual delete-user tool, by contrast, walks the admin through a
detailed preview (accounts, crackmes, cascaded solutions/comments/ratings,
notifications) before confirming.

Make approval use that same preview:

- The "Review & approve deletion" button now POSTs to a first step that
  resolves the target account and renders the shared deletion-impact
  breakdown; a second POST (action=confirm_delete) performs the deletion,
  marks the request approved, and emails the former user.
- Extract the preview markup/styles shared by both flows into a
  reviewer/_deletion_preview.html partial so the manual tool and the
  approval flow render an identical breakdown.

Approval remains admin-only (@admin_required, unchanged); only the reject
and list actions stay open to any reviewer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@xusheng6
xusheng6 force-pushed the feature/account-deletion-preview branch from 76f0777 to ea2885b Compare July 26, 2026 12:14
@xusheng6
xusheng6 merged commit d8ae600 into main Jul 26, 2026
4 checks passed
@xusheng6
xusheng6 deleted the feature/account-deletion-preview branch July 26, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant