Preview deletion impact before approving an account-deletion request - #177
Merged
Conversation
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
force-pushed
the
feature/account-deletion-preview
branch
from
July 26, 2026 12:14
76f0777 to
ea2885b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two things were asked:
Is "review & approve delete account" admin-only? — Yes, already. The
approveaccountdeletionroute 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.)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 JSconfirm()popup. The admin saw nothing about what would actually be removed. The manual/deleteusertool, in contrast, shows a detailed impact preview (the account, its crackmes, cascaded solutions/comments/ratings, notifications, and totals) before a final confirmation.Change
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.reviewer/_deletion_preview.htmlextracted fromdeleteuser.html, so the manual tool and the approval flow render an identical breakdown (no drift).deleteuser.htmlnow includes it too.@admin_required.Testing
test_admin_approves_deletion_and_emails_userto exercise both steps: first POST returns the preview (200) and deletes nothing; theconfirm_deletePOST deletes, marks approved, and sends the email.test_non_admin_cannot_approve_deletionstill 403s.🤖 Generated with Claude Code