Skip to content

Prevent admin from deleting their own account#284

Open
notvasub wants to merge 1 commit intomainfrom
vasu/remove-delete-account-admin
Open

Prevent admin from deleting their own account#284
notvasub wants to merge 1 commit intomainfrom
vasu/remove-delete-account-admin

Conversation

@notvasub
Copy link
Copy Markdown
Collaborator

@notvasub notvasub commented Apr 2, 2026

Prevent admins from deleting their own account through the dashboard. Without this guard, an admin could accidentally lock themselves out, which could destabilize access to the system.

Changes:

  • Added CannotDeleteOwnAccountException (403) to account_service.py
  • Updated DELETE /api/accounts/{account_id} router to capture the current admin's identity and raise 403 if they attempt to delete themselves
  • Added test_delete_own_account router test; updated test_delete_account_not_found to use a non-conflicting ID
  • Added isDeleteDisabled prop to TableTemplate to conditionally hide the Delete menu item per row
  • Hid the Delete option in AccountTable for the currently logged-in admin's own row

Closes #249

Added backend guard (403) and frontend UI restriction so admins cannot delete their own account from the dashboard. Includes a new router test covering the self-deletion case.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@notvasub notvasub requested a review from naasanov April 2, 2026 00:48
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Test Results Summary

542 tests  +1   542 ✅ +1   36s ⏱️ -3s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit d3c5af1. ± Comparison against base commit f3c29b9.

Copy link
Copy Markdown
Collaborator

@naasanov naasanov left a comment

Choose a reason for hiding this comment

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

I still see the delete button. Does it work on your end?

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.

"You Cannot Delete Your Own Account" For Admin

2 participants