Commit 89fd9a9
Fix CLI delete to use admin protection logic
Updates the CLI delete command to use UserManager.delete_user()
instead of direct session manipulation, ensuring consistent
admin protection between CLI and API endpoints.
Changes:
- Refactored delete command to call UserManager.delete_user()
- Added HTTPException handling for validation errors
- Updated all delete tests to mock UserManager instead of session
- Added test_delete_last_admin_blocked for admin protection
- Removed unnecessary try/except that immediately re-raised
The CLI now correctly prevents deletion of the last admin user,
matching the behavior of the API endpoint.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent dfcf950 commit 89fd9a9
2 files changed
+46
-47
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
359 | | - | |
| 359 | + | |
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
368 | 369 | | |
369 | 370 | | |
370 | 371 | | |
371 | | - | |
372 | | - | |
373 | 372 | | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
384 | 378 | | |
385 | 379 | | |
386 | 380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
570 | 567 | | |
| 568 | + | |
571 | 569 | | |
572 | 570 | | |
573 | 571 | | |
574 | 572 | | |
575 | | - | |
576 | | - | |
577 | | - | |
| 573 | + | |
578 | 574 | | |
579 | 575 | | |
580 | 576 | | |
581 | 577 | | |
582 | 578 | | |
583 | 579 | | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
596 | 583 | | |
| 584 | + | |
597 | 585 | | |
| 586 | + | |
598 | 587 | | |
599 | 588 | | |
600 | 589 | | |
| |||
604 | 593 | | |
605 | 594 | | |
606 | 595 | | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
612 | 602 | | |
| 603 | + | |
613 | 604 | | |
614 | 605 | | |
615 | 606 | | |
616 | 607 | | |
617 | | - | |
618 | | - | |
619 | | - | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
620 | 621 | | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
621 | 626 | | |
622 | 627 | | |
623 | | - | |
| 628 | + | |
624 | 629 | | |
625 | 630 | | |
626 | 631 | | |
| |||
0 commit comments